mozilla
Your Search Results

    document.getElementsByName Redirect 1

    « document

    Summary

    Returns a list of elements with a given name in the (X)HTML document.

    Syntax

    elements = document.getElementsByName(name) 
    
    • elements is an HTMLCollection of elements.
    • name is the value of the name attribute of the element.

    Example

    <!DOCTYPE html>
    <html lang="en">
    <head>
     ...
    </head>
    
    <body>
    <form name="up"><input type="text"></form>
    <form name="down"><input type="text"></form>
    
    <script>
    var up_forms = document.getElementsByName("up");
    w(up_forms[0].tagName); // returns "FORM"
    </script>
    </body>
    </html>
    

    Notes

    The name attribute is only applicable to (X)HTML documents. The method returns all elements with a name attribute, such as <meta> or <object> or even if name is placed on elements which do not support a name attribute at all.

    document.getElementsByName() returns an HTMLCollection of all the elements with a given value for the name attribute.

    Specifications

    Document Tags and Contributors

    Contributors to this page: Sheppy
    Last updated by: Sheppy,
    Hide Sidebar