Javascript getElementByID

tutorial and example
tutorial and example

JavaScript getElementById

The document.getElementById() method returns the element of specified id.

In below example we receive input field by using document.getElementById() method, here document.getElementById() receive input value on the basis of input field id.

Example

Try Now

Code Explanation

varnum=document.getElementById(“number”).value;

In this code getElementById value from input field which have Id number.

Example

Try Now