The onsearch event is useful for searches where the user presses the ENTER or "x" key within an input element. The type of is search because it is for users to search. Internet Explorer, Firefox, and Opera do not support the onsearch event.
You can try running the following code to learn how to implement the onsearch event in JavaScript.
<!DOCTYPE html> <html> <body> <p>Write what you want to search below and press "ENTER".</p> <input type = "search" id = "newInput" onsearch = "searchFunc()"> <script> function searchFunc() { var a = document.getElementById("newInput"); document.write("Searched = " + a.value); } </script> </body> </html>
The above is the detailed content of What is the usage of onsearch event in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!