Thursday, September 29, 2011

attr(Map)

attr(Map properties) returns jQuery
Set a key/value object as properties to all matched elements. This serves as the best way to set a large number of properties on all matched elements.

Example:

Sets src and alt attributes to all images.
$("img").attr({ src: "test.jpg", alt: "Test Image" });
HTML:

Result:
Test Image

No comments:

Post a Comment