JavaScript Reference/Javascript Methods/tags

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

"tags()" Example

    
<html>
<body>
<script language="JavaScript">
    function function1() {
        alert(document.all.tags("p").length);
    }
</script>
<p>This is a sample text.</p>
<p>This is another sample text.</p>
<p>This is another sample text.</p>
<p>This is another sample text.</p>
<input type="button" value="Number of p elements" onClick="function1();">
</body>
</html>



"tags()" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |all*                            anchors*                      |
|                |applets*                        areas*                        |
|                |boundElements*                  cells*                        |
|                |children*                       elements*                     |
|                |embeds*                         forms*                        |
|                |images*                         links*                        |
|                |options*                        plugins*                      |
|                |rows*                           scripts*                      |
|                |tBodies*                                                      |
+----------------+--------------------------------------------------------------+



"tags()" Syntax, Parameters and Note

Note:
Returns a list of tag name. 
Returns null if no match is found.
    
Syntax:
    
collectionName.tags(param1)
Parameters:
    param1   Required; the tag"s name.