I’ve a table containing a number of rows, where each row contains 3 td elements, the last of which is always a radio button.
I’ve a jquery function which is fired when any of these radio buttons is checked:
$('input[type=radio]').change(function() {
$('input[type=radio]').each(function(index) {
//remove class from tr
});
//add class selected to tr
});
What I’m looking to do is change the class of the tr containing the selected radio button to ‘selected’ and remove the class ‘selected’ from the previous selected option (for highlighting). Is there any way to access the tr from the radio button?
Try this:
Note that you could make it shorter with
$(':radio')rather than$('input[type=radio]').More Info: