Attributes exists in HTML tag. For example, class attribute in below tag
JavaScript has the following call to manipulate the attribute in a specific tag.
hasAttribute() tests if the attribute exists in the tag
getAttribute() retrieve the value of the attribute such as "show" above
setAttribute() set a value to the attribute
removeAttribute() remove the attribute from the tag
For example,
document.getElementById("pic").getAttribute("class")
No comments:
Post a Comment