Find all divs with contenteditable attribute in iframe and remove specified attribute with jQuery?

I have an ifram on the page with the ms-dlgFrame class, and in this iframe I want to remove contenteditable = "true" on the elements since it is not supported by Safari on the iPad (I check the user agent first).

I have some problems with combining .find(), .each(), .attr() and .removeAttr()

I tried something like:

 console.log("iPad"); $('.ms-dlgFrame').contents().find("div").attr("contenteditable").each(function() { $(this).removeAttr("contenteditable"); }); 

Any ideas?

Thanks in advance.

+4
source share
1 answer

Try the div[contenteditable='true'] selector div[contenteditable='true'] and release the attr() call from your chain:

 console.log("iPad"); $('.ms-dlgFrame').contents().find("div[contenteditable='true']").each(function() { $(this).removeAttr("contenteditable"); }); 
+8
source

All Articles