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

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

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

Answers (1)

Add Answer
Staff answered 3 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