小编Sla*_*vak的帖子

jQuery在prev中找到相同的td.和下一行

我有一张桌子,我知道如何搜索下一个和上一个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)

css jquery click

8
推荐指数
1
解决办法
9330
查看次数

标签 统计

click ×1

css ×1

jquery ×1