js:appendchild无效果
代码如下
<table class="table table-bordered data-table" id="table1">
<thead>
<tr>
<th>学号</th>
<th>密码</th>
<th>姓名</th>
<th>性别</th>
</tr>
</thead>
<tbody id="thebody">
<tr id="person" style="display:none" class="gradeX" name="person" >
<td><input type="text" name="personId" id="personId"
onkeyup="document.getElementById('pwd'+this.id).value =this.value;"></td>
<td><input type="text" name="pwd" id="pwd" ></td>
<td><input type="text" name="name" id="name"></td>
<td>
<select id="sex" name="sex" value="${param.select}">
<option value="男">男</option>
<option value="女">女</option>
</select>
</td>
<td><input type="text" name="isadmin" value="false" readonly="true" id="isadmin" style="display:none"></td>
</tr>
<tr class="gradeX" name="person0" id="person0">
<td><input type="text" name="personId0" id="personId0"
onkeyup="document.getElementById('pwd'+this.id).value =this.value;"></td>
<td><input type="text" name="pwd0" id="pwdpersonId0" ></td>
<td><input type="text" name="name0" id="name"></td>
<td>
<select id="sex" name="sex0" value="${param.select}">
<option value="男">男</option>
<option value="女">女</option>
</select>
</td>
<td><input type="text" name="isadmin0" value="false" readonly="true" id="isadmin" style="display:none"></td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var i=0;
function addNewTr(){
++i;
var v=$("#person").clone();
v.attr("id","person"+i);
var name="#person"+i;
v.attr("style","display:block");
$(name+" #personId").attr("name","personId"+i);
$(name+" #personId").attr("id","personId"+i);
$(name+" #pwd").attr("name","pwd"+i);
$(name+" #pwd").attr("id","pwdpersonId"+i);
$(name+" #name").attr("name","name"+i);
$(name+" #sex").attr("name","sex"+i);
$(name+" #isadmin").attr("name","isadmin"+i);
$("#thebody").appendChild(v);/********************* 这里添加v后没有显示出来 ************************/
alert($(name+" #name").attr("name"));
}
</script>