Reputation: 1047
Is there any event available for clicking reset button appears on html5 search input element?
Upvotes: 0
Views: 5637
Reputation: 1975
The event is called search
. It is fired on both: the search and the reset.
You just need to check if the query is empty or not.
For example:
$("#searchInput").on("search", function(evt){
if($(this).val().length > 0){
// the search is being executed
}else{
// user clicked reset
}
});
It works, here is the fiddle: https://fiddle.jshell.net/ye1dabap/
Upvotes: 8