Open In App
Related Articles

HTML DOM item() Method

Improve Article
Save Article
Like Article

The item() method is used to return the node at the specified index. The nodes are sorted as they appear in the source code. The index of the node list starts with 0. 


nodelist.item( index )


nodelist[ index ] 

Parameters: This method accepts single parameter index which is used to hold the index of node which need to return. It is required parameter and the index starts with 0. 

Return Value: This method returns the node at specified index. 



<!DOCTYPE html>
        HTML DOM item() Method
    <!-- script to change node value -->
        function changeElement() {
            var gfg = document.getElementById("geeks");
            gfg.getElementsByTagName("P")[1].innerHTML = 
                             "Welcome to GeeksforGeeks!";
        <div id="geeks">
            <h1 style="color:green;">GeeksforGeeks</h1>
            <p>A computer science portal</p>
            <p>DOM item() Method</p>
        <button onclick="changeElement()">
            Click Here!

Output: Before Click on the button:


After Click on the button:


Supported Browsers: The browser supported by DOM item() Method are listed below:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 5 and above
  • Firefox 1 and above
  • Opera 12.1 and above
  • Safari 1 and above

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 12 Jun, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials