📌  相关文章
📜  addeventlistener javascript 多个函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:50.640000             🧑  作者: Mango

代码示例3
// events and args should be of type Array
function addMultipleListeners(element,events,handler,useCapture,args){
  if (!(events instanceof Array)){
    throw 'addMultipleListeners: '+
          'please supply an array of eventstrings '+
          '(like ["click","mouseover"])';
  }
  //create a wrapper to be able to use additional arguments
  var handlerFn = function(e){
    handler.apply(this, args && args instanceof Array ? args : []);
  }
  for (var i=0;i