What is the usage of onsearch event in JavaScript?

WBOY
Release: 2023-09-27 15:49:02
forward
843 people have browsed it

What is the usage of onsearch event in JavaScript?

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.

Example

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>
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template