HTML中动态加入行和并在input域上加入onclick事件

来源:互联网 发布:section软件使用 编辑:程序博客网 时间:2024/05/20 02:22
// 之前出现问题js无响应html += "<li style='cursor:pointer;' onclick='openCenter('"+data.resJson.root[i].cardId+"');'>" + data.resJson.root[i].cardName + "</li>";// 改为html += "<li style='cursor:pointer;' onclick=\"openCenter('"+data.resJson.root[i].cardId+"');\">" + data.resJson.root[i].cardName + "</li>";//-------------------------------------------------------------------------------function addRow(){    var myTable = document.getElementById("myTable");    var j=myTable.rows.length;    var row = myTable.insertRow();    var cell1 = row.insertCell() ;    //给td加入样式,spacenew是你定义的样式名称    cell1.setAttribute("className","spacenew");    //合并表格    cell1.setAttribute("colSpan",3);    var text1 = document.createElement("input");    text1.type = "button";    text1.name = "buttonC"+j;    text1.value = "选择";    //加入onclick事件    text1.onclick = Function("return selectFromParaList('a','b')");   cell1.appendChild(text1);}function selectFromParaList(a,b){    alert(a+b);}






                                             
0 0
原创粉丝点击