admin管理员组

文章数量:1289425

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 bining .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.

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 bining .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.

Share Improve this question edited Dec 13, 2012 at 14:20 Michael Berkowski 271k47 gold badges450 silver badges393 bronze badges asked Jun 30, 2011 at 2:08 johnjohn 531 silver badge6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

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

本文标签: