You are here: Reference > JavaScript > client-side > xml handling > properties > nodeTypeString (attribute, Element, ...)
nodeTypeString property (attribute, Element, ...)
Returns the type of the current node as a string.
This property is not supported in HTML documents, only in XML documents.
The nodeType property is similar to the nodeTypeString property, but it returns an integer that represents the type of a node. The nodeType property is supported by the all commonly used browsers in HTML and XML documents also, use it instead.
The nodeType property is similar to the nodeTypeString property, but it returns an integer that represents the type of a node. The nodeType property is supported by the all commonly used browsers in HTML and XML documents also, use it instead.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read-only.
Possible values:
String that retrieves the type.
One of the following values:
The nodeType is ELEMENT_NODE (1) | |||||||
The nodeType is ATTRIBUTE_NODE (2) | |||||||
The nodeType is TEXT_NODE (3) | |||||||
The nodeType is CDATA_SECTION_NODE (4) | |||||||
The nodeType is ENTITY_REFERENCE_NODE (5) | |||||||
The nodeType is ENTITY_NODE (6) | |||||||
The nodeType is PROCESSING_INSTRUCTION_NODE (7) | |||||||
The nodeType is COMMENT_NODE (8) | |||||||
The nodeType is DOCUMENT_NODE (9) | |||||||
The nodeType is DOCUMENT_TYPE_NODE (10) | |||||||
The nodeType is DOCUMENT_FRAGMENT_NODE (11) | |||||||
The nodeType is NOTATION_NODE (12) |
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the nodeTypeString property:
|
|||||
<head> <script type="text/javascript" src="ajax.js"></script> <script type="text/javascript"> function GetNodeTypes () { // create an XML document var xmlDoc = CreateXMLDocumentObject ("root"); // defined in ajax.js if (!xmlDoc) { return null; } alert ("The type of the document: " + xmlDoc.nodeTypeString); alert ("The type of the root node: " + root.nodeTypeString); } </script> </head> <body> <button onclick="GetNodeTypes ();">Get different node types!</button> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments