<html>
<head>
</head>
<body>
<table id="mytable>
<thead> <tr> ...... </tr> </thead>
<tbody> <tr> ...... </tr> </thead>
<thead> <tr> ...... </tr> </thead> // how to remove this thead using jquery?
</table>
</body>
</html>
我需要从表thead
中删除第二个mytable
。这个选择器是什么?我试过这个。
$("#mytable").find("thead").eq(1) // not working or by using nth-child for thead still not working
答案 0 :(得分:3)
使用 remove()
删除dom元素
$("#mytable").find("thead").eq(1).remove()
// or
// $("#mytable thead:eq(1)").remove()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="mytable">
<thead>
<tr><td>. First THead .</td></tr>
</thead>
<tbody>
<tr><td> TBody </td></tr>
</tbody>
<thead>
<tr><td>.Last THead.</td></tr>
</thead>
</table>