JavaScript Reference/Javascript Methods/getElementsByTagName

Материал из Web эксперт
Версия от 11:22, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"getElementsByTagName()" Example

   <source lang="javascript">
   

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

   var m = document.getElementsByTagName("P");
   alert(m.length); 

} </script> <input type="button"

      value="Get the number of p elements in this page" 
      onClick="function1();">

</body> </html>


     </source>
   
  


"getElementsByTagName()" is applied to

   <source lang="javascript">

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

| |
|

| |<body>
| | |<button> |

| |
|

| | <col> | | |<colgroup> <custom> | | |

| | | <dir> |

| |
|

| |document

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

| |<hn>
|

| |<html> | | |<iframe> <img> | | | <isindex> | | | <label> |

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

      <param> | | |<plaintext>

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

        "getElementsByTagName()" Syntax, Parameters and Note

        <source lang="javascript"> Note: Returns elements by tag name.

        Syntax:

        document.getElementsByTagName(param1) document.all.elementID.getElementsByTagName(param1) // IE only Parameters: param1 Required; the tag name.


        </source>

      <textarea> | | |<tfoot> |

      | |<thead> <title> |

      | |