specified property
Gets a value that indicates whether an attribute is explicitly given a value.
Syntax
| JavaScript | |
|---|
Property values
Type: Boolean
one of the following values.Standards information
- Document Object Model (DOM) Level 1 Specification, Section 1.2
Remarks
An attribute value is specified if it is assigned through HTML or script.
Windows Internet Explorer 9. When webpages are displayed in IE9 Standards mode, the attributes collection does not contain attributes that are not specifically created (unlike previous Windows Internet Explorer versions). As a result, the specified property returns true for every item in the attributes collection.
Examples
The following code example uses the specified property to determine the attributes that are set for an object. The function checks each attribute and lists all of the attributes of the object and their values.
<script type="text/javascript"> function fnFindSpecified(){ var oAttributes=oList.attributes; alert(oAttributes(0).nodeName); for(var i=0;i<oAttributes.length;i++){ var oNode=document.createElement("LI"); var oNodeValue=document.createTextNode(i + " " + oAttributes(i).nodeName + " = " + oAttributes(i).nodeValue); oList.appendChild(oNode); oNode.appendChild(oNodeValue); if(oAttributes(i).nodeValue!=null){ alert(oAttributes(i).nodeName + " specified: " + oAttributes(i).specified); } } } </script> <ul id="oList" onclick= "fnFindSpecified()"> <li>Click to Find Specified Attributes</li> </ul>
See also
Show: