Input Search value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Search


The value property sets or gets the value attribute of a search field.

Set the value property with the following Values

Value Description
text Sets the value of the search field

Return Value

A String, representing the value of the search field

The following code shows how to change the text of a search field:

Demo Code

ResultView the demo in separate window

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

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

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

function myFunction() {//ww  w.  j ava 2s  . c  o m
    document.getElementById("mySearch").value = 20;
    document.getElementById("demo").innerHTML = 'changed';


Related Tutorials