JavaScript Reference/Javascript Methods/getElementsByTagName
"getElementsByTagName()" Example
<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>
"getElementsByTagName()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<a> <acronym> |
| |<address> <applet> |
| |<area> <b> |
| |<base> <basefont> |
| |<bdo> <bgsound> |
| |<big> <blockquote> |
| |<body> <br> |
| |<button> <caption> |
| |<center> <cite> |
| |<code> <col> |
| |<colgroup> <custom> |
| |<dd> <del> |
| |<dfn> <dir> |
| |<div> <dl> |
| |document <dt> |
| |<em> <embed> |
| |<fieldset> <font> |
| |<form> <frame> |
| |<frameset> <head> |
| |<hn> <hr> |
| |<html> <i> |
| |<iframe> <img> |
| |<ins> <isindex> |
| |<kbd> <label> |
| |<legend> <li> |
| |<link> <listing> |
| |<map> <marquee> |
| |<menu> <meta> |
| |<noframes> <noscript> |
| |<object> <ol> |
| |<optgroup> <option> |
| |<p> <param> |
| |<plaintext> <pre> |
| |<q> <s> |
| |<samp> <script> |
| |<select> <small> |
| |<span> <strike> |
| |<strong> <style> |
| |<sub> <sup> |
| |<table> <tbody> |
| |<td> <textarea> |
| |<tfoot> <th> |
| |<thead> <title> |
| |<tr> <tt> |
| |<u> <ul> |
| |<var> <xmp> |
+----------------+--------------------------------------------------------------+
"getElementsByTagName()" Syntax, Parameters and Note
Note:
Returns elements by tag name.
Syntax:
document.getElementsByTagName(param1)
document.all.elementID.getElementsByTagName(param1) // IE only
Parameters:
param1 Required; the tag name.