jQuery code examples that let you understand quickly how to change single or multiple attributes values also how to get attribute value.
Changing value of Single Attribute
$("a").attr("href", "http://freetemplate.website");
$("img").attr("src", "/images/banner.jpg");
Changing value of Single Attribute with callback function
$("div").attr("id", function (arr) {
return "div-id" + arr;
})
Changing values of multiple attributes in same html tag
$("img").attr({
src: "/images/banner.jpg",
title: "banner",
alt: "banner"
});
Getting attribute value
var $source = $("img").attr("src");