Tagged: Working with Attributes
jQuery
by
Subbu
· Published June 21, 2013
Setting Single Attribute $(“img”).attr(“src”, “http://cdn.css-tricks.com/images/banner.jpg”); Setting Single Attribute (with function) $(“div”).attr(“id”, function (arr) { return “div-id” + arr; }) Setting Multiple Attributes $(“img”).attr({ src: “http://cdn.css-tricks.com/images/banner.jpg”, title: “banner”, alt: “banner” }); Getting Attribute var $source...
jQuery
by
Subbu
· Published April 20, 2013
Setting Single Attribute $(“img”).attr(“src”, “/images/banner.jpg”); Setting Single Attribute (with function) $(“div”).attr(“id”, function (arr) { return “div-id” + arr; }) Setting Multiple Attributes $(“img”).attr({ src: “/images/banner.jpg”, title: “banner”, alt: “banner” }); Getting Attribute var $source...