Javascript Reference - HTML DOM Input Search type Property








The type property gets the type string of the search field.

Browser Support

type Yes Yes Yes Yes Yes

Syntax

var v = searchObject.type

Return Value

A String type value representing the type of the search field.





Example

The following code shows how to get type string of the search field.


<!DOCTYPE html>
<html>
<body>
<!--from  w w w . j  a  v a2  s  . c  o m-->
Search: <input type="search" id="mySearch">
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySearch").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: