Input Button type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button

Description

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>
<html>
<body>

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

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

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

</body>
</html>

Related Tutorials