
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Usage of onsearch Event in JavaScript
The onsearch event is useful for search i.e. a user press ENTER or “x” key in input element. The type for <input> is search, since it is for users to search. The onsearch event isn’t supported in Internet Explorer, Firefox, and Opera.
Example
You can try to run the following code to learn how to implement 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>
Advertisements