HTML | onsearch Event Attribute
This onsearch attribute works when a user presses the ENTER button or click on the x button. This event works with <input> element.
Syntax:
<element onsearch="script">
Attribute: This event contains single attribute script which contains the script to be run when event call.
Example:
<!DOCTYPE html> <html> <head> <title>onsearch event</title> <style> .gfg { font-size:40px; color:green; font-weight:bold; } body { text-align:center; } </style> </head> <body> <div class = "gfg">GeeksforGeeks</div> <h2>onsearch event attribute</h2> <input type="search" id="geeks" onsearch="geeksforgeeks()"> <p id="geek"></p> <script> function geeksforgeeks() { var x = document.getElementById("geeks"); document.getElementById("geek").innerHTML = "Searching Content: " + x.value; } </script> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browsers supported by onsearch Event Attribute are listed below:
- Apple Safari
- Google Chrome
- Opera 15.0
Recommended Posts:
- HTML | ondragleave Event Attribute
- HTML | onmouseup Event Attribute
- HTML | ondragstart Event Attribute
- HTML | onwheel Event Attribute
- HTML | onmousemove Event Attribute
- HTML | onload Event Attribute
- HTML | onkeydown Event Attribute
- HTML | onmouseover Event Attribute
- HTML | oncontextmenu Event Attribute
- HTML | onsubmit Event Attribute
- HTML | ondragover Event Attribute
- HTML | onmouseout Event Attribute
- HTML | onreset Event Attribute
- HTML | onunload Event Attribute
- HTML | onpaste Event Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



