内容简介:代码日志版权声明:翻译自:http://stackoverflow.com/questions/14061123/jquery-selector-to-grab-cells-in-the-same-column
给定一个多行多列表,如何选择与任意单元格(例如点击的单元格)相同列中的所有单元格.
就像是:
$("td").click(function(){
var columnNo = $(this).columnNo?
$(this).closest("table").find("tr td:eq("+columnNo+")").css("color", "red");
});
我需要这样做,而不必单独命名列.例如.它应该适用于简单的通用表标记,而不需要额外的类或ID.
您的尝试是正确的,所有您需要做的是使用
.index
找到列号 –<td>的索引在行内.您还需要使用 nth-child-selector
来匹配其他<td>的列索引.元素. $("td").click(function(){
var columnNo = $(this).index();
$(this).closest("table")
.find("tr td:nth-child(" + (columnNo+1) + ")")
.css("color", "red");
});
代码日志版权声明:
翻译自:http://stackoverflow.com/questions/14061123/jquery-selector-to-grab-cells-in-the-same-column
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Squid: The Definitive Guide
Duane Wessels / O'Reilly Media / 2004 / $44.95 US, $65.95 CA, £31.95 UK
Squid is the most popular Web caching software in use today, and it works on a variety of platforms including Linux, FreeBSD, and Windows. Squid improves network performance by reducing the amount of......一起来看看 《Squid: The Definitive Guide》 这本书的介绍吧!