jquery .on('input') doesn't get fired in ie8 alone

I'm having this issue specific to IE8. This event doesn't fire in IE8 alone, but is working fine in IE9 and other browsers like Firefox and Chrome.

$('#myId').on('input', function () {
   //do something.
}

Please let me know if there is any work around for the same in IE8.

Thanks!

oninput is IE9+, that is why it does not work in IE8

MDN oninput

Feature         Chrome    Firefox    Internet Explorer    Opera    Safari
Basic support   (Yes)     2          9                    10       (Yes)

jQuery, jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly  jQuery's event system requires that a DOM element allow attaching data via a property on the element, so that events can be tracked and delivered. The object, embed, and applet elements cannot attach data, and therefore cannot have jQuery events bound to them.

Older versions of IE have an event called propertychange that you can use. You can check for the propertychange event and the input event at the same time:

$('#myId').on("propertychange input",function(ev){
    doAwesomeThing();
});

What is jquery.min.js?, The on() method attaches one or more event handlers for the selected elements and child elements. As of jQuery version 1.7, the on() method is the new replacement for the bind(), live() and delegate() methods. This method brings a lot of consistency to the API, and we recommend that you use this method, as it simplifies the jQuery code base.

AaronBaker's answer: Works for both IE8 and IE10(html5) as well as modern browsers... without double post of event

I would have used comment or upvote but rep too low.

$('#myId').on("propertychange input",function(ev){
    doAwesomeThing();
});

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.

It looks like the input event is a part of the HTML5 specification, something I wouldn't expect IE8 to handle. You may need to use the change event instead.

$.click() is merely a shortcut for either bind or on. From jQuery docs: In the first two variations, this method is a shortcut for .bind("click", handler), as well as for .on("click", handler) as of jQuery 1.7. In the third variation, when .click() is called without arguments, it is a shortcut for .trigger("click").

This slight optimization will prevent the listener from firing twice in modern browsers (kind of a hack, but prob the best solution)

$('selector').on(!window.eventListener ? 'keyup' : 'input', function () {}

This page documents data types appearing in jQuery function signatures, whether defined by JavaScript itself or further restricted by jQuery. Unless explicitly stated otherwise, jQuery functions require primitive values where applicable, and do not accept their Object-wrapped forms. If you want to study these concepts in depth, take a look at MDN.

jQuery Tutorial - jQuery is a fast and concise JavaScript library created by John Resig in 2006. jQuery simplifies HTML document traversing, event handling, animating, and Ajax i

jQuery is tailor-made to respond to events in an HTML page. All the different visitors' actions that a web page can respond to are called events. An event represents the precise moment when something happens. The term "fires/fired" is often used with events. Example: "The keypress event is fired, the moment you press a key".

The mouseover () method triggers the mouseover event, or attaches a function to run when a mouseover event occurs. Note: Unlike the mouseenter event, the mouseover event triggers if a mouse pointer enters any child elements as well as the selected element. The mouseenter event is only triggered when the mouse pointer enters the selected element

Comments
  • I don't recognize "input" as an event trigger, myself. Maybe I've just never seen it?
  • Try using change or keyup instead, input isn't supported in older browsers.
  • @VoidKing and everyone that upvoted your comment: Learn about it: MDN oninput
  • On a side note make sure you aren't using jquery 2.0+ it doesn't support old IE versions.
  • The input event is a new event, is't not supported in IE8
  • Note that IE9 also doesn't support oninput well, see stackoverflow.com/questions/6382389/…
  • Works for me. Thanks a lot.
  • Works but fires property change event twice in IE8 ... used 'keyup input' instead and it worked!
  • Confirmed, Justin's solution above works like a charm. Thanks!