删除所有属性

是否可以使用jQuery一次删除所有属性

<img src=”https://stackoverflow.com/questions/1870441/example.jpg“width=“100”height=“100”>

<img>

我尝试了$('img')。removeAttr('*')</没有运气。有人吗

一个不需要JQuery的简单方法:

while(elem.attributes.length&gt;0)
elem.removeAttribute(elem.attributes[0].name);

发表评论