开发者

Find a table row below to highlight 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜