javascript getElementsByTagName() method


  Translation results:

get

英[get] 美[ɡɛt]

vt.Get; catch; persuade; receive (punishment, etc.)

vt.& vi. Arrive, come

vi. Become; start; try to deal with; obtain benefits or wealth

n. Reproduce, cub; profit

Third person singular : gets present participle: getting past tense: got past participle: got gotten

element

##英[ˈelɪmənt] US[ˈɛləmənt]

n. element; [chemical] element; principle; [electricity] resistance wire

plural: elements

by

英[baɪ] 美[baɪ]

prep. Beside...; Expression method; Because; Passed

adv. Passed; Used to indicate retention or preservation; Short visit

tag

英[tæg] 美[tæɡ]

vt.

Attach; add tag to; prosecute; follow closely

vi.

Follow behind...;follower

n.

tag; appendage; catchphrase; title

Third person singular: tags Plural: tags Present participle: tagging Past tense : tagged

##name

英[neɪm] 美[nem]

n. Name; reputation; having a name; famous person

vt. Determine; decide; name...; name... Present participle: naming Past tense: named Past participle: named

javascript getElementsByTagName() methodsyntax

Function: Returns a collection of objects with the specified tag name.

Syntax: document.getElementsByTagName(tagname)

Description: getElementsByTagName() method returns the elements in the order they are in the document Order. If you pass the special string "*" to the getElementsByTagName() method, it will return a list of all elements in the document, and the order in which the elements are arranged is the order in which they appear in the document.

Note: The string passed to the getElementsByTagName() method can be case-insensitive.

javascript getElementsByTagName() methodexample

<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript">
        function getElements()
        {
            var x=document.getElementsByTagName("input");
            alert(x.length);
        }
    </script>
</head>
<body>

<input name="myInput" type="text" size="20" /><br />
<input name="myInput" type="text" size="20" /><br />
<input name="myInput" type="text" size="20" /><br />
<br />
<input type="button" onclick="getElements()"
       value="How many input elements?" />

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A