How to use DOM Object GetElementByName in JavaScript

In this article I am going to explain about DOM Object getElementByName() method in JavaScript.
  • 1503

JavaScript DOM Object getElementByName() Method

JavaScript getElementByName() method use for access to element with the specified given name.

Syntax

document.getElementByName(name)

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            var mm = document.getElementsByName("Add");

            alert(mm.length);

        }

    </script>

</head>

<body>

    <h4 name="Add">

        Shayam</h4>

    <h4 name="Add">

        Ajay</h4>

    <h4 name="Add">

        Abhishek</h4>

    <button onclick="myfun()">

        click me</button>

</body>

</html>

 

Output

 

 getelementbyname.gif

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.