<script language="javascript">
var number = 0;
//新增一行
function getNewRowStr(){
number++;
var str = '';
str = "<tr id='"+number+"'>"
+ "<td style='width:43px;'><input id='zybj"+number+"' name='zybj"+number+"' class='textInput'></td>"
+ "<td style='width:50px'><input id='ypyl"+number+"' name='ypyl"+number+"' class='textInput' ></td>"
+ "<td style='width:28px'><select id='yfyl"+number+"' name='yfyl"+number+"' style='width:56px'><option value=''>请选择</option>${pcbmxs}</select></td>"
+ "<td style='width:28px'><input id='ts"+number+"' name='ts"+number+"' class='textInput'></td>" <!--天数-->
+ "<td style='width:59px'><select id='fsbm"+number+"' name='fsbm"+number+"' style='width:112px'><option value=''>请选择</option>${fsbmxs}</select></td>"
+ "<td style='width:28px'><select id='zxfs"+number+"' name='zxfs"+number+"'>" <!--服法-->
+ "<option value=''>请选择</option>"
+ "<option value='0'>遵医嘱</option>"
+ "<option value='1'>口服</option>"
+ "<option value='2'>按说明书</option>"
+ "<option value='3'>外服内服</option>"
+ "</select></td>"
+ "<td style='width:28px'><input id='dw"+number+"' name='dw"+number+"' class='textInput'></td>"
+ "<td style='width:58px'><input id='cfsl"+number+"' name='cfsl"+number+"' class='textInput'></td>"
+ "<td style='width:58px'><select id='zbybs"+number+"' name='zbybs"+number+"' style='width:115px'>"
+ "<option value=''>请选择</option>"
+ "<option value='0'>否</option>"
+ "<option value='1'>是</option>"
+ "</select></td>"
+ "<td style='width:58px'>"
+ "<select id='yzzs"+number+"' name='yzzs"+number+"' style='width:117px '><option value=''>请选择</option>${yzzsxs}</select>"
+ "<input id='mtlbbm"+number+"' name='mtlbbm"+number+"' type='hidden'>"
+ "<input id='flh3"+number+"' name='flh3"+number+"' type='hidden'>"
+ "<input id='jg"+number+"' name='jg"+number+"' type='hidden'>"
+ "</td>"
+ "<td style='width:20px'>"
+ "<a class='btnDel' href='javascript:delete();' οnclick='var table=this.parentNode.parentNode.parentNode;table.removeChild(this.parentNode.parentNode);'><span>删除</span></a>"
+ "</td>"
+ "</tr>"
$("#addDrug").append(str);
$("#number").val(number);
}
</script>
简单理解为:
<table>
<tr ><td>1</td>
<td>2</td>
<td>3</td>
<td><a id="11" href="javascript:delete();" οnclick="var table=this.parentNode.parentNode.parentNode;table.removeChild(this.parentNode.parentNode);">删除</a></td>
</tr>
<tr >
<td>11</td>
<td>22</td>
<td>33</td>
<td><a id="11" href="javascript:delete();" οnclick="var table=this.parentNode.parentNode.parentNode;table.removeChild(this.parentNode.parentNode);">删除</a></td>
</tr>
</table>