Export (0) Print
Expand All
all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize

specified property

Gets a value that indicates whether an attribute is explicitly given a value.

Syntax

JavaScript

p = object.specified

 

Property values

Type: Boolean

one of the following values.

true (true)

Attribute values were explicitly specified.

false (false)

Attribute values were not specified.

Standards information

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

attribute
About the W3C Document Object Model

 

 

Show:
© 2014 Microsoft