【发布时间】:2014-05-25 04:50:52
【问题描述】:
我对 addEventListener 方法很陌生。我正在尝试使用 addEventListener 将参数传递给函数。但它不是 worining。为什么我不能使用 addEventListener 方法传递字符串“2a”?如果你这样做会很有帮助给我解释一下这个问题。谢谢
<html>
<head>
<style>
.mm{
width:100px;
height:60px;
}
</style>
</head>
<body>
<script>
function lister(){
document.getElementById("tab1").addEventListener("click",myfunc("2a"));
}
function myfunc(str){
alert(str);
}
window.onload=listener;
</script>
<table style="border:1px solid black;padding:2px;margin:2px 2px 2px 2px;">
<tr><td class="mm" id="tab1">this is it</td></tr>
<tr><td class="mm" id="tab2">no tis titt</td></tr>
</table>
</body>
</html>
【问题讨论】:
标签: javascript