Isarius
Isarius

Reputation: 91

Find a table row below to highlight it

I got checkbox:

<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.

Upvotes: 3

Views: 858

Answers (1)

Samich
Samich

Reputation: 30105

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");
    });
});

Upvotes: 5

Related Questions