THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

onsearch Event

Event Object Reference Event Object

Example

Execute a JavaScript when submitting a search:

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

Definition and Usage

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

In JavaScript:

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

In JavaScript, using the addEventListener() method:

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

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Technical Details

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

Event Object Reference Event Object