onsearch Event

Example

Call a function when submitting a search:

<input type="search" onsearch="myFunction()">
Try it Yourself »

Description

The onsearch event occurs when a user presses the "ENTER" key or clicks the "x" button in an <input> element with type="search".


Browser Support

The numbers in the table specify the first browser version that fully supports the event.

Event
onsearch Yes Not supported Not supported Yes 15.0

Syntax

In HTML:

<element onsearch="myScript">
Try it Yourself »

In JavaScript:

object.onsearch = function(){myScript};
Try it Yourself »

In JavaScript, using the addEventListener() method:

object.addEventListener("search", myScript);
Try it Yourself »

Technical Details

Bubbles: No
Cancelable: No
Event type: Event
HTML tags: <input type="search">
DOM Version: Level 3 Events

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.