1 m = 0 ;// 用于区分input 2 // 新增一条录入 3 function AddTR(){ 4 m += 1; 5 var tableObject = document.getElementById("fpqk_tab"); 6 var oTr = tableObject.rows[1]; 7 var newTr = oTr.cloneNode(true); 8 tableObject.getElementsByTagName("tbody")[0].appendChild(newTr); 9 newTr = tableObject.rows[tableObject.rows.length-1]; 10 newInputs= newTr.getElementsByTagName("input"); 11 newTd = newTr.lastChild; 12 newTd.innerHTML = "<a href='#' οnclick='DelRow(this)' id = 'del_input' title='删除此行' >删除</a>"; 13 for(i=0;i<newInputs.length;i++){ 14 newInputs[i].id = newInputs[i].id + m ; // 用于区分input 15 } 16 document.getElementById("but_add"+m).onclick = function(){SelectUserSingle('hydm'+m,'hyxm'+m,'','form1')} 17 document.getElementById("but_del"+m).onclick = function(){ClearUser('hydm'+m,'hyxm'+m);}
// 有些浏览器不支持setAttribute()方法,建议使用以上方法代替; 18 //document.getElementById("but_add"+m).setAttribute("onclick","alert( '本时间段秒杀结束,请关注下一时间段!')"); 19 //document.getElementById("but_del"+m).setAttribute("onclick","ClearUser('hydm"+m+"','hyxm"+m+"')"); 20 //$("but_add"+m).bind('onclick',function(){ClearUser('hydm'+m,'hyxm'+m);}); 21 }
转载于:https://www.cnblogs.com/itaceo-o/p/3407491.html