jQuery如何在Firefox中模拟`focusin`事件?

时间:2016-02-27 00:33:49

标签: javascript jquery firefox javascript-events

我读了MDN page,上面写着

  

Firefox中尚不支持此事件,请参阅错误687787.可以使用焦点事件,这也与事件委派兼容。

latest jQuery source

// Support: Firefox
// Firefox doesn't have focus(in | out) events
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
// Support: Chrome, Safari
// focus(in | out) events fire after focus & blur events, 
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
// Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857

我创建了以下jsFiddle页面来测试focusin事件在Firefox中是否有效。看起来很有效。注意:我知道这个事件focus()事件本身是通过jQuery对象调用的,但即使我手动点击任何方块,Firefox也会触发该事件。

https://jsfiddle.net/beatak/8grhLusj/14/

我更关心的是我是否可以跨浏览器方式使用jQuery的focusin/out事件,显然,它适用于Firefox。我不熟悉jQuery.event.simulate()的作用,我想知道是否有人可以解释它在Firefox中是如何工作的,这样我就可以更自信地使用jQuery的模拟focusin/out事件了。

0 个答案:

没有答案