elem["on"+type] = ata; //这里为什么要用到方括号才可以呢?求解
elem+".on"+type = ata; //这个经我测试是不行的
var $ = function(id){return document.getElementById(id)}
function ata(){
alert("sd")
}
function ads2(elem,type){
console.log(elem)
elem["on"+type] = ata;
console.log(elem["on"+type])
}
ads2($("cl"),"click")
elem+".on"+type = ata; //这个经我测试是不行的
var $ = function(id){return document.getElementById(id)}
function ata(){
alert("sd")
}
function ads2(elem,type){
console.log(elem)
elem["on"+type] = ata;
console.log(elem["on"+type])
}
ads2($("cl"),"click")
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货