Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find all div's with contenteditable attribute in iframe and remove said attribute with jQuery?

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

I have some issues 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.

like image 581
john Avatar asked Dec 28 '22 18:12

john


1 Answers

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

console.log("iPad");
$('.ms-dlgFrame').contents().find("div[contenteditable='true']").each(function() {
    $(this).removeAttr("contenteditable");
});
like image 114
Michael Berkowski Avatar answered Jan 25 '23 22:01

Michael Berkowski