The best HTML DOM access Tutorial In 2024, In this tutorial you can learn Access HTML elements (nodes),getElementById () method,Examples,getElementsByTagName () method,Example 1,Example 2,The getElementsByClassName () Method,
Access to HTML DOM - find HTML elements.
Access HTML elements equivalent to Access Node
You can be in a different way to access HTML elements:
getElementById () method returns the element with the specified ID:
The following example Get id = "intro" element:
getElementsByTagName () returns all elements with the specified tag name.
The following example returns a list of documents that contain all the <p> element:
The following example returns a list of documents that contain all the <p> element, and the <p> element should be a descendant id = "main" element (child, Sun, etc.):
If you want to find all HTML elements with the same class name, use this method:
Returns a list containing the above example class = "intro" all the elements:
Note: getElementsByClassName () is not valid in 5,6,7,8 in Internet Explorer.