关于动态获取onClick事件问题

function addRow()
{
var myTable = document.getElementById("myTable");
var j=myTable.rows.length;
var row = myTable.insertRow();
var cell1 = row.insertCell() ;
var text1 = document.createElement("input");
text1.type = "button";
text1.name = "buttonC"+j;
text1.value = "选择";
text1.onClick = "return selectFromParaList('a','b')";
cell1.appendChild(text1);
}

可是,我在动态增加了一行后,点“选择”按钮,没有任何响应,感觉是onClick事件没有起作用。

请高手指点。
---------------------------------------------------------------

 1<script language="javascript">   
 2function addRow()   
 3{   
 4var myTable = document.getElementById("myTable");   
 5var j=myTable.rows.length;   
 6var row = myTable.insertRow();   
 7var cell1 = row.insertCell() ;   
 8var text1 = document.createElement("input");   
 9text1.type = "button";   
10text1.name = "buttonC"+j;   
11text1.value = "选择";   
12text1.onclick = Function("return selectFromParaList('a','b')");   
13cell1.appendChild(text1);   
14}   
15  
16function selectFromParaList(a,b)   
17{   
18alert(a+b);   
19}   
20</script>
1<input onclick="addRow()" type="button" value="addRow"/>
1<table border="1" id="myTable">
2</table>
Published At
Categories with Web编程
comments powered by Disqus