JavaScript Reference/Javascript Methods/getElementsByTagName
"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> | | |
<textarea> | | |<tfoot> | | |<thead> <title> |
| || | | | | | <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>