最近有个需求,需要对一个table在特定情况下修改第几个td的样式,这里需要使用到html" title=jquery>jquery选择器了,我的写法是,这里改为直接隐藏元素了:
$('.divdemo>table tr').each(function(){
//每个tr下的第4个th
$(this).find('th:eq(3)').hide();
$(this).find('th:eq(4)').hide();
//每个tr下的第4个td
$(this).find('td:eq(3)').hide();
$(this).find('td:eq(4)').hide();
})
关于html" title=jquery>jquery选择器的使用,我之前写了一篇文章,需要的可以参考:jQuery:选择器使用详解