Input Button type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button


The type property returns the type of form element.

For an input button this property always returns "button".

Return Value

A String, representing the type of form element

The following code shows how to return type of form element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<input type="button" onclick="myFunction()" id="myBtn" value="Test">

<p id="demo"></p>

function myFunction() {/*  w ww  . j  av a  2s .co m*/
    var x = document.getElementById("myBtn").type;
    document.getElementById("demo").innerHTML = x;


Related Tutorials