Javascript examples for DOM Event:Element Event Attribute
The onsearch event occurs when a user presses the "ENTER" key or clicks the "x" button in an <input> element with type="search".
Bubbles | No |
---|---|
Cancelable | No |
Supported HTML tags: | <input type="search"> |
<!DOCTYPE html> <html> <body> <input type="search" id="myInput"> <p id="demo"></p> <script> document.getElementById("myInput").onsearch = function() {myFunction()}; function myFunction() {//from w w w. ja v a 2 s . co m var x = document.getElementById("myInput"); document.getElementById("demo").innerHTML = "You are searching for: " + x.value; } </script> </body> </html>