HTML DOM Input Search type property


The HTML DOM Input search type property is associated with the input element having its type=”search”. It will always return search for the input search element.

Syntax

Following is the syntax for search type property −

searchObject.type

Example

Let us look at an example for the Input search type property −

Live Demo

<!DOCTYPE html>
<html>
<body>
<h1>Search type property</h1>
<form>
FRUITS: <input type="search" id="SEARCH1" name="fruits">
</form>
<p>Get the above element type by clicking the below button</p>
<button onclick="getType()">Get Type</button>
<p id="Sample"></p>
<script>
   function getType() {
      var t = document.getElementById("SEARCH1").type;
      document.getElementById("Sample").innerHTML = "The type for the input field is : "+t;
   }
</script>
</body>
</html>

Output

This will produce the following output −

On clicking the “Get Type” button −

Updated on: 19-Feb-2021

81 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements