Created
December 3, 2013 18:05
-
-
Save enopanen/7774302 to your computer and use it in GitHub Desktop.
This property is relatively straightforward but I always see these problems in StackOverflow. You can pull the .attr() method on any HTML element and pass in the attribute string value. This will return the value of that attribute, whether it’s ID or class or name or maxlength. All HTML attributes may be accessed through this syntax and so it’s …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "the classiest search engine", | |
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