Javascript examples for DOM HTML Element:Input Search
The readOnly property sets or gets whether a search field should be read-only.
This property reflects the HTML readonly attribute.
Set the readOnly property with the following Values
Value | Description |
---|---|
true|false | Sets whether a search field should be read-only |
A Boolean, returns true if the search field is read-only, otherwise it returns false
The following code shows how to Set a search field to read-only:
<!DOCTYPE html> <html> <body> Search: <input type="search" id="mySearch" readonly> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww .j a va 2s . c o m var x = document.getElementById("mySearch").readOnly; document.getElementById("demo").innerHTML = x; } </script> </body> </html>