What is document.getElementById in javascript? What it will return?

Forums JavaScriptWhat is document.getElementById in javascript? What it will return?
Staff asked 2 years ago

What is document.getElementById in javascript? What it will return? Explain with an example.

Answers (1)

Add Answer
Umang Ramani Marked As Accepted
Staff answered 2 years ago

The function getElementById() retrieves an element with the supplied value and value mus be a Id of an element

If the element does not exist, the getElementById() function returns null.

One of the most frequent methods in the HTML DOM is getElementById().

It is nearly often used when you wish to read or update an HTML element.

Subscribe

Select Categories