Skip to content
Related Articles

Related Articles

Improve Article

HTMLCollection namedItem() Method

  • Difficulty Level : Basic
  • Last Updated : 13 Aug, 2021

The namedItem() Method is used to return the element with having the specified ID, OR, name or content in an HTML element collection in the document.




Parameters: It contains the name as its parameters values which represent the ID OR name attribute that the user want to return.
Return Value: It returns  an Element object, representing the element at with specified ID or name. otherwise, it returns null if the element does not exist.



<!DOCTYPE html>
        h1 {
            color: green;
        <h2>HTMLCollection namedItem() Method</h2>
        <p id="GFG">
          The namedItem() method is used to return
          the content of the element with the specified
          ID or name Attribute values
        <button onclick="Geeks()">Submit</button>
            function Geeks() {
                var w =


After clicking on Submit: 

Supported Browsers: The browser supported by HTMLCollection NAMEDitem() Method are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :