将多个事件绑定到侦听器(没有JQuery)?
在处理浏览器事件时,我已经开始将Safari的touchEvents集成到移动设备中。我发现addEventListeners与条件堆叠在一起。该项目不能使用JQuery。 标准事件侦听器: /* option 1 */ window.addEventListener('mousemove', this.mouseMoveHandler, false); window.addEventListener('touchmove', this.mouseMoveHandler, false); /* option 2, only enables the required event */ var isTouchEnabled = window.Touch || false; window.addEventListener(isTouchEnabled ? 'touchmove' : 'mousemove', this.mouseMoveHandler, false); jQuery bind允许多个事件,如下所示: $(window).bind('mousemove touchmove', function(e) { //do something; }); 是否有办法像JQuery示例中那样组合两个事件侦听器?例如: window.addEventListener('mousemove touchmove', this.mouseMoveHandler, false); 任何建议或提示,不胜感激!