首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

关于使用javascript自动添加表格后给单元格赋行为的有关问题

2012-02-04 
关于使用javascript自动添加表格后给单元格赋行为的问题使用rowtbl.insertRow()cellrow.insertCell()

关于使用javascript自动添加表格后给单元格赋行为的问题
使用
row   =   tbl.insertRow();
cell   =   row.insertCell();
添加行和列之后,如何给行和列赋行为,我使用row.onMouseOver   =   fun();之后,在fun()中加入alert( "test ");测试发现每次添加行或者列之后都会调用这个函数,但是当我鼠标移动到该行之后却无法引发行为。
不想在cell中加入 <div   onMouseOver= "fun() "> text </div> 这样的语句,请问如果添加。
谢谢各位先。

[解决办法]
<script type= "text/javascript ">
function dd(){
var a=document.getElementById( "tab ")
row = a.insertRow();
cell = row.insertCell();
cell.innerText= "11111111111 "
row.onmouseover=func

}

function func(){
alert( "?? ")
}
</script>
<input type= "button " value= "press " onclick= "dd() ">
<table id= "tab ">
[解决办法]
function dd(){
var a=document.getElementById( "tab ")
row = a.insertRow();
cell = row.insertCell();
cell.innerText= "11111111111 "
row.onmouseover=function(){func11( "3333 ")}

}

function func(){
alert( "?? ")
}
function func11(a){
alert(a)
}
</script>
<input type= "button " value= "press " onclick= "dd() ">
<table id= "tab ">


</table>
[解决办法]
或者attachEvent( "onmouseover ",function)也可以

热点排行