Javascript examples for DOM HTML Element:Input Search
The size property sets or gets the size attribute of a search field, which sets the width of a search field in number of characters.
The default value is 20.
Set the size property with the following Values
Value | Description |
---|---|
number | Sets the width of the search field, in number of characters. |
A Number, representing the width of the search field, in number of characters
The following code shows how to change the width of a search field:
<!DOCTYPE html> <html> <body> Search: <input type="search" id="mySearch" size="35"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w.j a va 2 s . co m*/ var x = document.getElementById("mySearch").size; document.getElementById("demo").innerHTML = x; } </script> </body> </html>