I understand that this question was answered, but the accepted answer did not work in our situation. IE10 did not recognize / the $input.trigger("cleared"); statement did not work $input.trigger("cleared"); .
Our final solution replaced this statement with the keydown event on the ENTER key (code 13). For posterity, this is what worked in our case:
$('input[type="text"]').bind("mouseup", function(event) { var $input = $(this); var oldValue = $input.val(); if (oldValue == "") { return; } setTimeout(function() { var newValue = $input.val(); if (newValue == "") { var enterEvent = $.Event("keydown"); enterEvent.which = 13; $input.trigger(enterEvent); } }, 1); });
In addition, we wanted to apply this binding only to the "search" inputs, and not to all the inputs on the page. Naturally, IE also made it harder ... although we encoded <input type="search"...> , IE displayed them as type="text" . Therefore, the jQuery selector refers to type="text" .
Hurrah!
OrangeWombat Apr 09 '14 at 17:01 2014-04-09 17:01
source share