JQuery Input Event does not Fire if Input is Empty

javascript-eventsjquery

I have a jQuery event handler that reacts to every change in an

<input id="myId" type="text" /> 

element:

$("#myId").bind('input', function (e) {    
        // Do Stuff
    });

This works perfectly, except when the input in #myId is empty (e.g. there was just 1 character in the input box, and I remove it with Backspace). If the input has become empty, the event does not fire. If I then enter a character, the event fires.

Is this a known issue? Am I doing something wrong? Any way to get an event when the input goes empty?

Update

The event does not fire AT ALL when Backspace is entered, at least in IE9.

Best Solution

as far as I know, "input" is not the event you want to use. Since "input" is analogous to "change", it tends to produce a bad result when your string approaches 0 chars, use keyup instead

$("input#myId").bind('keyup', function (e) {    
    // Do Stuff
});