Removing multiple attributes with jQuery removeAttr

I have the following code.

$(document).ready(function(){ $('#listing img') .attr('width', 250) .removeAttr('height').removeAttr('align').removeAttr('style') .wrap('<p />'); }); 

Is there a more efficient way to remove multiple attributes?

+61
jquery
Dec 05
source share
1 answer

Yes:

 .removeAttr('height align style') 

From the documentation :

since version 1.7, this may be a list of attributes separated by a space.

+125
Dec 05
source share



All Articles