
hasAttribute
hasAttribute is a boolean value indicating whether the current element has the specified attribute or not.
Syntax
[ true | false ] = element.hasAttribute(attName)
Parameters
boolean true | false
attName is a string representing the name of the attribute
Example
// check that the attirbute exists
// before you set a value
d = document.getElementById("div1");
if d.hasAttribute("align") {
d.setAttribute("align", "center");
}
|
Notes
None.
Specification
hasAttribute
Netscape Communications
http://developer.netscape.com
|