比如说.这样一段代码:
function aa(){
alert("hello");
}
var test=document.getElementById("test");
test.onclick=aa;
那么点击test的时候就会弹出hello.
现在把代码改成这样:
function bb(id){
var str="hello"+id;
alert(str);
}
var test=document.getElementById("test");
那么就不能直接把句柄赋给click事件了,test.onclick=bb;,也不能写成test.onclick=bb(test.id);
那我该怎么写呢?谢谢!
function aa(){
alert("hello");
}
var test=document.getElementById("test");
test.onclick=aa;
那么点击test的时候就会弹出hello.
现在把代码改成这样:
function bb(id){
var str="hello"+id;
alert(str);
}
var test=document.getElementById("test");
那么就不能直接把句柄赋给click事件了,test.onclick=bb;,也不能写成test.onclick=bb(test.id);
那我该怎么写呢?谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货