Language References
Retrieves whether an attribute has been specified.
HTML |
N/A |
Script |
[ bSpecified = ] object.specified |
true |
The attribute is specified. |
false |
The attribute is not specified. |
The property is read-only with no default value.
An attribute set via HTML or script is considered to be specified.
The following sample demonstrates the use of the specified property to determine if an attribute is specified by the author. The results are produced using the createElement method to create a new LI object, the createTextNode method to create a new text node, and the appendChild method to add the new elements to the list.
<script language="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>
<li>Click to Find Specified Attributes
</ul>
Attribute