52,797
社区成员
发帖
与我相关
我的任务
分享
function createRowItem(rowId)
{
var rows=$("#tab_OrderDetail tr");
var rowLen=rows.length;
var rowN= rowId+1;
if(rowN==rowLen)
{
var tr=$("<tr>").append("<td>"+rowN+"</td><td><input type=\"text\" id=\"truckName_"+rowN+"\"/></td><td><input type=\"text\" id=\"truckCode_"+rowN+"\"/></td><td><select id=\"truckType_"+rowN+"\"><option >0</option></select></td><td><input type=\"text\" id=\"configuration_"+rowN+"\"/></td><td><input type=\"text\" id=\"price_"+rowN+"\"/></td><td><input type=\"text\" id=\"Amount_"+rowN+"\"/></td><td><input type=\"text\" id=\"totalMoney_"+rowN+"\"/></td><td><select id=\"consignType_"+rowN+"\"><option>0</option></select></td><td><input type=\"text\" id=\"consignTime_"+rowN+"\"/></td>");
tr.attr("id", (rowN));
$("#tab_OrderDetail").append(tr);
$("#consignTime_"+rowN+"").attr("onclick",createRowItem(rowN));
}else{ return;}
}
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
$(function(){
$("#row_1").one("click",function(){addRow($(this).attr("id"))});
});
function addRow(rowid)
{
var nextRowid = "row_"+(rowid.split("_")[1]+1);
$($("#"+rowid).clone()).appendTo($("#test")).attr("id",nextRowid).one("click",function(){ addRow(nextRowid)});;
}
//]]>
</script>
<body>
<table id="test">
<tr id="row_1">
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
</body>