JavaScript Reference/Javascript Properties/nodeType

Материал из Web эксперт
Перейти к: навигация, поиск

"nodeType" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function3() {

  alert(document.all.myNodeOne.nodeType);

} </script>

This PARAGRAPH has two nodes, Node One, and Node Two.

<button onclick="function3();">Node One Type</button> </body> </html>


     </source>
   
  


"nodeType" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> attribute | | | <base> | | |<basefont> | | |<bgsound> |

| |
<body> |

| |
<button> |

| |
|

| | | | |<col> <colgroup> | | |<comment>

| | | |

| |<dir>
| | |
| | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|

| |<html> | | |<iframe> <img> | | |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="hidden"> | | |<input type="image"> <input type="password"> | | |<input type="radio"> <input type="reset"> | | |<input type="submit"> <input type="text"> | | | <isindex> | | | <label> |

| |<legend>
  • | | |<link> <listing> | | |<map> <marquee> | | |<menu> <meta> | | |<noframes> <noscript> | | |<object>
      | | |<optgroup> <option> | | |

      <param> | | |<plaintext>

                               |
      |                |                                                        |
      |                |                          <script>                      |
      |                |<select>                                               |
      |                |                                                |
      |                |                        <style>                       |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                                                       |
      |                |
        | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>

        "nodeType" Possible Values

        <source lang="javascript"> Possible Values 1 for element node, 3 for text node. IE6 returns 2 for an attribute node. NN6+ supports other values as well: 8 for a comment node and 9 for a document node.


        </source>



        "nodeType" Syntax and Note

        <source lang="javascript"> Note: Read-only property. Returns the node type.

        Syntax:

        document.getElementById("elementID").nodeType document.all.elementID.nodeType // IE only


        </source>

      <textarea> |

      | |TextNode <tfoot> |

      | |
      <thead> | | |<title>