开发者

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

开发者 https://www.devze.com 2023-03-16 03:16 出处:网络
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 th

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.


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");
});
0

精彩评论

暂无评论...
验证码 换一张
取 消