HTML DOM getElementById() Method

The getElementById() method returns the element of specified ID. It returns null if the element with specified ID is not found. It is the most common DOM method, which is used to manipulate or get info from a DOM element. The syntax of getElementById() method is as follows :
Where the elementID is ID of the element of the element we want to manipulate. Also note that an ID should be unique within a  page, if more than one element within the same ID, then the getElementById method will return the first element in the source code.

Example :
  <p id="demo">Hello world, This is a test Paragraph.</p>
  <button onclick="myfunc()">Click Here</button>
    function myfunc() {
      var x = document.getElementById("demo"); = "yellow"; = "blue"; = "bold"; = "20px";
Output :

Hello world, This is a test Paragraph.

Next Topic :