DOM Method :
1.getElementsByTagName : method returns a collection of all elements in the document with the
specified tag name, as an HTML collection object.The HTML collection object represents a collection
of nodes. The nodes can be accessed by index numbers. The index starts at 0.
syntax : document.getElementsByTagName("p").;
2.getElementById : method returns the element that has the ID attribute with the specified value.
1.getElementsByTagName : method returns a collection of all elements in the document with the
specified tag name, as an HTML collection object.The HTML collection object represents a collection
of nodes. The nodes can be accessed by index numbers. The index starts at 0.
syntax : document.getElementsByTagName("p").;
2.getElementById : method returns the element that has the ID attribute with the specified value.
This method is one of the most common methods in the HTML DOM, and is used almost every time
you want to manipulate, or get info from, an element on your document.
syntax : document.getElementById("demo").innerHTML = "Hello World";
3.getElementsByClassName : returns a collection of all elements in the document with the
specified class name, as an HTML collection object.The HTML collection object represents a
collection of nodes. The nodes can be accessed by index numbers. The index starts at 0.
4.querySelectorAll : method returns all elements in the document that matches a specified CSS
selector(s), as a static NodeList object.The NodeList object represents a collection of nodes.
The nodes can be accessed by index numbers. The index starts at 0.
5.getAttribute : The getAttribute() method returns the value of the attribute with the specified name
, of an element.
syntax : var x = document.getElementsByTagName("H1")[0].getAttribute("class");
specified class name, as an HTML collection object.The HTML collection object represents a
collection of nodes. The nodes can be accessed by index numbers. The index starts at 0.
syntax : document.getElementsByClassName("demo").;
4.querySelectorAll : method returns all elements in the document that matches a specified CSS
selector(s), as a static NodeList object.The NodeList object represents a collection of nodes.
The nodes can be accessed by index numbers. The index starts at 0.
syntax : x = document.querySelectorAll(".example");
5.getAttribute : The getAttribute() method returns the value of the attribute with the specified name
, of an element.
syntax : var x = document.getElementsByTagName("H1")[0].getAttribute("class");
ScreenShots
1
2
3
4
5
6
Name : Thakor Hardik
Id No : 18CE129





