如何使用 jQuery 从 div 中删除 id 属性?

我想从这张图片中移除 id 属性:

<img width="270" class="thumb" id="thumb" height="270" src="img/1_1.jpg" />

我试过这么做:

$('img#thumb').RemoveAttr('id','none');

但它没有移除 ID!

编辑:

$('img#thumb').attr('src', response);
$('img#thumb').attr('id', 'nonthumb');

这个 deosnt 加载图片,或者在这种情况下 src!但是当我删除 id 属性时,它可以正常工作

169342 次浏览

The capitalization is wrong, and you have an extra argument.

Do this instead:

$('img#thumb').removeAttr('id');

For future reference, there aren't any jQuery methods that begin with a capital letter. They all take the same form as this one, starting with a lower case, and the first letter of each joined "word" is upper case.

I'm not sure what jQuery api you're looking at, but you should only have to specify id.

$('#thumb').removeAttr('id');