Reputation: 1725
$(myelem).removeAttr('attributeName');
Does not work in IE 7. The suggested workaround is:
$(myelem).prop("attributeName", false);
or
$(myelem).prop("attributeName", null);
or
$(myelem).attr("attributeName", '');
These are all fine if you want to change the rendering or the behaviour. What I need to is to actually remove the attribute from the source. E.g.
<p align="center">
should become
<p>
The examples above are focused on doing this
<p align="">
Which would change the alignment, but the attribute is still there.
Anyone now a way or really deleting the attribute?
I'm using JQuery 1.6.1
Upvotes: 2
Views: 851
Reputation: 1391
Try replacing the p tag completely, with a new p tag without the attribute:
$(myelem).replaceWith("<p>"+$(myelem).html()+"</p>");
Upvotes: 2
Reputation: 12294
myelem.removeAttribute('attribute name');
This should work, as far as I know the only attributes IE7 is unable to remove are event handlers.
See this link for removeAttribute compatibility.
Upvotes: 2