Skip to content
Related Articles

Related Articles

HTML | onsearch Event Attribute

View Discussion
Improve Article
Save Article
Like Article
  • Difficulty Level : Basic
  • Last Updated : 09 Mar, 2022

This onsearch attribute works when a user presses the ENTER button or click on the x button. This event works with <input> element.
Supported Tags: 


<element onsearch="script">

Attribute: This event contains single attribute script which contains the script to be run when event call.


<!DOCTYPE html>
        <title>onsearch event</title>
            .gfg {
            body {
    <div class = "gfg">GeeksforGeeks</div>
    <h2>onsearch event attribute</h2>
    <input type="search" id="geeks" onsearch="geeksforgeeks()">
    <p id="geek"></p>
        function geeksforgeeks() {
            var x = document.getElementById("geeks");
            document.getElementById("geek").innerHTML =
                   "Searching Content: " + x.value;


Supported Browsers: The browsers supported by onsearch Event Attribute are listed below: 

  • Apple Safari
  • Google Chrome
  • Opera 15.0


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!