使用jQuery突出显示表格中的列 [英] Highlighting columns in a table with jQuery
本文介绍了使用jQuery突出显示表格中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表,并且正在使用jquery突出显示表中的备用列
I have a table and I am highlighting alternate columns in the table using jquery
$("table.Table22 tr td:nth-child(even)").css("background","blue");
但是,我在<tr>
中还有另一个<table>
作为最后一行.如何避免突出显示<tr>
内的表的列?
However I have another <table>
inside a <tr>
as the last row. How can I avoid highlighting columns of tables that are inside <tr>
?
推荐答案
使用>
后代选择器对其进行限定:
Qualify it with the >
descendant selector:
$("table.Table22 > tbody > tr > td:nth-child(even)").css("background","blue");
您还需要tbody
限定符,因为浏览器会自动插入tbody
是否在标记中.
You need the tbody
qualifier too, as browsers automatically insert a tbody
whether you have it in your markup or not.
编辑:呜呜.谢谢安南.
编辑2 :强调肢体.
这篇关于使用jQuery突出显示表格中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文