Javascript 使用jquerywhere类删除th标记

Javascript 使用jquerywhere类删除th标记,javascript,jquery,Javascript,Jquery,如何使用jquerywhere类删除th标记 我的桌子: <table> <thead> <th class="NoRemove">1</th> <th>2</th> <th class="NoRemove">3</th> <th class="NoRemove">4</th> <th class="NoRemove">5</th> <th>

如何使用jquerywhere类删除th标记

我的桌子:

<table>
<thead>
<th class="NoRemove">1</th>
<th>2</th>
<th class="NoRemove">3</th>
<th class="NoRemove">4</th>
<th class="NoRemove">5</th>
<th>6</th>
<th>7</th>
</thead>
</table>
我需要将上述代码写入jQuery。但是我不知道怎么写

//dom ready handler - wait the execution of the passed function till the dom is loaded
jQuery(function(){
    //fetch all the th elements which does not have the class NoRemove and remove it
    $('th:not(.NoRemove)').remove()
})
参考:

演示:

我会使用:

然而,有成千上万种不同的方式去做!这就是jQuery如此出色的原因。

为此任务使用
.not()
:not()
jQuery方法。
//dom ready handler - wait the execution of the passed function till the dom is loaded
jQuery(function(){
    //fetch all the th elements which does not have the class NoRemove and remove it
    $('th:not(.NoRemove)').remove()
})
$(function(){
    $('table th').filter(':not(.NoRemove)').remove();
});
$('table th:not(".NoRemove")').remove();