开发者

Find a table row below to highlight it

开发者 https://www.devze.com 2023-04-11 22:36 出处:网络
I got checkbox: 开发者_如何学JAVA<input class=\"_checkbox\" type=\"checkbox\"/> And , when I click it:

I got checkbox:

开发者_如何学JAVA<input class="_checkbox" type="checkbox"/>

And , when I click it:

$(function() {
    $('._checkbox').click(function() {
        [..]
    });
});

I need to highlight a table row that is below the checkbox. I've tried with :

$(function() {
    $('._checkbox').click(function() {
        $(this).siblings("#table_row").css("background-color", "blue");
    });
});

But doesn't work.

I guess I'll have to add some unique IDs, but have no idea how should I read them , etc.


If you mean that you next row after the current one with checkbox then define current row and get next:

$(function() {
    $('._checkbox').click(function() {
        $(this).closest('tr').next().css("background-color", "blue");
    });
});

If you need to hightlight current one:

$(function() {
    $('._checkbox').click(function() {
        $(this).closest('tr').css("background-color", "blue");
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消