2015-11-04 4 views
1
<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. Что будет для этого селектором? Я пробовал с этим.селектор Jquery, чтобы найти THEAD

$("#mytable").find("thead").eq(1) // not working or by using nth-child for thead still not working 

ответ

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>

Смежные вопросы