Input Search type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Search

Description

The type property returns the type of form search field.

For a search field, this property will always return "search".

Return Value

A String, representing the type of form element the search field is

The following code shows how to return which type of form element the search field is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Search: <input type="search" id="mySearch">

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {// w ww . java  2s  .c o  m
    var x = document.getElementById("mySearch").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials