Setting attributes of an element in jQuery

To set single/multiple attributes of an element in jQuery, refer following snippet:

$(“img”).attr({
		“src” : “/images/smile.jpg”,
		“alt” : “Smile”,
		“width”  : 10,
		“height” : 10});

//above code snippet will set multiple mentioned attributes of image.

For any query. Reach me.


Anoop kumar Sharma

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>