In JavaScript, using the addEventListener()
method:
object.addEventListener("search",
myScript);
This example uses the addEventListener()
method to attach a "search" event to an input element.
Write something in the search field and press "ENTER".
The search event is not supported in Internet Explorer, Firefox.
<!DOCTYPE html> <html> <body> <input type="search" id="myInput"> <p id="demo"></p> <script> document.getElementById("myInput").addEventListener("search", myFunction); function myFunction() {/*ww w . j av a 2 s . c o m*/ var x = document.getElementById("myInput"); document.getElementById("demo").innerHTML = "You are searching for: " + x.value; } </script> </body> </html>
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <input type="search"> |