请高手帮忙,如何给动态创建的表格添加事件??
我用javascript和dom动态创建了一个表格,现在想给表格的一个列添加onmouseover事件,但不知如何实现。请各高手帮帮忙了,分数不多,但已是我最后的分数了。
------解决方案-------------------- <table id= "tab ">
<tr> <td> 123 </td> </tr>
</table>
<script>
var tab=document.getElementById( "tab ");
AddTableEvent(tab,show);
function show(){
alert( "hello table! ");
}
function AddTableEvent(table,fun){
table.rows[0].onmouseover=fun;
}
</script>
------解决方案--------------------function AddRows(){
tb = document.all.DetailTable;
if ( tb.style.display == "none "){
tb.style.display = " ";
}
index = tb.rows.length;
var row =tb.insertRow();
row.id = "tr "+index;
var cell2 = row.insertCell();
var cell3 = row.insertCell();
var cell4 = row.insertCell();
cell2.innerHTML= " <input type=text name=mname size=10 id=mname onmouseover= 'open() '> ";
cell3.innerHTML= " <input type=text name=num size=10 id=num> ";
cell4.innerHTML= " <input type=text name=mark size=10 id=mark> ";
}