Skip to content

Instantly share code, notes, and snippets.

@jlittlejohn
Created December 13, 2012 21:35
Show Gist options
  • Save jlittlejohn/4280177 to your computer and use it in GitHub Desktop.
Save jlittlejohn/4280177 to your computer and use it in GitHub Desktop.
JS: Setting & Getting Attributes
var alink = $("a#user").attr("href"); // obtain href attribute value
$("a#user").attr("href", "http://www.google.com/"); // set the href attribute to a new value
$("a#user").attr({
alt: "Google",
href: "http://www.google.com/"
}); // set more than one attribute to new values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment