4

Is it reasonably fine to bind an event handler to an element both on the 'input' and 'propertychange' events to target support for IE8 and other browsers?

$('.element').on('input propertychange', function(){...});

Or are there pitfalls to doing this?

Edit

Is there a jQuery plugin I can use to support old version of IE?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Sam
  • 6,414
  • 11
  • 46
  • 61

1 Answers1

2

It's not exactly the same. It'll fire when there are JavaScript changes, and not just user changes.

This means that a major pitfall is that you can have infinite recursion if the handler provided makes a JavaScript change to the same input, or if there's any sort of circular reference, where inputA changes inputB, which changes inputA.

I was actually working on this earlier today, hoping to find any small differences in the event object that would let me differentiate between user originating changes, and JavaScript changes, but I could find none.

Edit

See this blog post for a possible jQuery plugin.