However, it is a bit hacky and ggutenberg's answer will work for most people.
$('#search-field').on('click', function(){
$('#search-field').on('search', function(){
if(!this.value){
console.log("clicked x");
// Put code you want to run on clear here
}
});
setTimeout(function() {
$('#search-field').off('search');
}, 1);
});
Where '#search-field'
is the jQuery selector for your input. Use 'input[type=search]'
to select all search inputs. Works by checking for a search event (Pauan's answer) immediately after a click on the field.