How to remove id attribute from div using jQuery?

I want to remove the id attribute from this image:

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

I tried to do this:

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

But it does not delete the identifier!

EDIT:

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

This does not load the image, or in this case src! But when I remove the id attribute, it works fine

+48
javascript jquery html image
Jan 04
source share
2 answers

The law is wrong, and you have an additional argument.

Do this instead:

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

For future reference, there are no jQuery methods that start with a capital letter. All of them have the same form as this one, starting with the lower case, and the first letter of each of the connected β€œwords” is the upper case.

+112
Jan 04 2018-11-11T00:
source share

I'm not sure if the jQuery api you are looking at, but you only need to specify id .

 $('#thumb').removeAttr('id'); 
+10
Jan 04 2018-11-11T00:
source share



All Articles