8

What event is triggered when a user clicks the X in a search input field (in webkit browsers) to cancel the search or clear the text?

Information is available about restyling the button and other custom events, but not on using this button.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
jmilloy
  • 7,875
  • 11
  • 53
  • 86

1 Answers1

13

The onsearch event is triggered both when the search input is submitted and when the user clears the search.

<input type=search onsearch="javascript:alert('SEARCH: ' + this.value);" />
jmilloy
  • 7,875
  • 11
  • 53
  • 86