How to set and get Attributes in JQuery

Goud.Kv
Posted by Goud.Kv under jQuery category on | Points: 40 | Views : 568
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

Comments or Responses

Login to post response