使用 initEvent 创建事件和稍后在 JavaScript 中使用 dispatchEvent 调度事件和使用 jquery 的 trigger('click')触发器有什么区别
问问题
2090 次
1 回答
4
jQuery的trigger
功能不一样dispatch
,见下表来自bugs.jquery.com/ticket/11047
"The trigger function should also dispatch custom events such that code using addEventListener can catch the custom event. However, that is not happening. In fact, that is the only of the 8 combinations listed below that does not work. We should fix this to allow better interoperability between jQuery event functions and W3C DOM event functions."
PASS: If you trigger a DOM event you can catch it using the bind function
PASS: If you trigger a DOM event you can catch it using the addEventListener function
PASS: If you trigger a custom event you can catch it using the bind function
FAIL: If you trigger a custom event you can NOT catch it using the addEventListener function
PASS: If you dispatch a DOM event you can catch it using the bind function
PASS: If you dispatch a DOM event you can catch it using the addEventListener function
PASS: If you dispatch a custom event you can catch it using the bind function
PASS: If you dispatch a custom event you can catch it using the addEventListener function
于 2012-07-25T15:56:33.940 回答