我有一张桌子,我知道如何搜索下一个和上一个TD,但如何在下一个和上一个TR?
012
345 <- example, I clicked on 4, it checks 3 and 5, but how to check on 0,1,2 and 6,7,8?
678
Run Code Online (Sandbox Code Playgroud)
$(document).ready(function() {
$("td").click(function() {
var x = $(this).next().css('backgroundColor');
var y = $(this).prev().css('backgroundColor');
if (x == 'rgb(255, 0, 0)' || y == 'rgb(255, 0, 0)') {
return;
} else {
$(this).css('backgroundColor', 'red');
}
});
});
Run Code Online (Sandbox Code Playgroud)
Sla*_*vak 10
我做了一些研究,并提出了一个有效的工作解决方案.谢谢大家的帮助:
$(this).parent().next().find('td').eq($(this).index()-1).css('backgroundColor');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9330 次 |
| 最近记录: |