动态添加事件的问题,请高手指点,在线等待!
怎样为新生成的一行增加一个onclick事件?
a.insertRow();……下面代码怎么写????注意是<tr>的oncilck事件
a.insertRow();……下面代码怎么写????注意是<tr>的oncilck事件
...全文
请发表友善的回复…
发表回复
kurz_78 2003-10-21
- 打赏
- 举报
多谢!给分。。。
利而不害 2003-10-21
- 打赏
- 举报
a.insertRow();
a.setAttribute("onclick", aa);
function aa()
{
alert('click');
}
a.setAttribute("onclick", aa);
function aa()
{
alert('click');
}
longshenwang 2003-10-21
- 打赏
- 举报
关注...
cloudchen 2003-10-21
- 打赏
- 举报
var tr = a.insertRow();
tr.onclick = function() {
.....
.....
}
tr.onclick = function() {
.....
.....
}
kingdomzhf 2003-10-21
- 打赏
- 举报
<body>
<table border=1 id=t1>
<tr><td>a</td></tr>
</table>
<input type=button onclick="var oRow = t1.insertRow();var oCell = oRow.insertCell();oCell.innerHTML = 'AA';oRow.attachEvent('onclick',aa);">
<script>
function aa()
{
alert('click');
}
</script>
</body>
<table border=1 id=t1>
<tr><td>a</td></tr>
</table>
<input type=button onclick="var oRow = t1.insertRow();var oCell = oRow.insertCell();oCell.innerHTML = 'AA';oRow.attachEvent('onclick',aa);">
<script>
function aa()
{
alert('click');
}
</script>
</body>