Below code explains Setting and Getting attributes in JQuery.
var al = $("a#user").attr("href");
// obtaining href attribute value
$("a#user").attr("href", "http://www.google.com/");
// setting the href attribute to a new value
$("a#user").attr({
alt: "The Famous Search Engine",
href: "http://www.google.com/"
});
// can set more than one attribute to new values