读书人

循环增添事件

发布时间: 2012-09-29 10:30:01 作者: rapoo

循环添加事件

Function.prototype.bind = function(){ // 自己定义的方法  var oThis = this, args = Array.prototype.slice.call(arguments), obj = args.shift();  return function (){  oThis.apply(obj, args);  }  }  function aa()   {     var radio = document.getElementsByName("attr");     for(var i=0;i  <radio.length;i++)     {  radio[i].onclick = bb.bind(radio[i],i);    }   }     function bb(i)   {     alert(i);   }  aa(); 


读书人网 >Web前端

热点推荐