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 |
A String, representing the value of the search field
The following code shows how to change the text of a search field:
<!DOCTYPE html> <html> <body> Search: <input type="search" id="mySearch" value="Food"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//ww w. j ava 2s . c o m document.getElementById("mySearch").value = 20; document.getElementById("demo").innerHTML = 'changed'; } </script> </body> </html>