kgp43
asked on
Limit jQuery to each table, possible?
Hi,
I use the following jQuery to change tr background color when clicking table rows (radio input).
The problem is, I have quite a few tables containing different type of data. User click a row which is then selected and marked (background change).
Is it possible to make jQuery limited by table/div name, id or class?
Background color (active) is reset when I click a row in another table.
Current:
Maybe something like this (probably not valid):
I use the following jQuery to change tr background color when clicking table rows (radio input).
The problem is, I have quite a few tables containing different type of data. User click a row which is then selected and marked (background change).
Is it possible to make jQuery limited by table/div name, id or class?
Background color (active) is reset when I click a row in another table.
Current:
$(document).ready(function() {
$('input[type=radio]').change(function(){
$('tr.active').removeClass('active');
$(this).parents('tr').addClass('active');
});
});
Maybe something like this (probably not valid):
$(document).ready(function() {
$('#divID.input[type=radio]').change(function(){
$('tr.active').removeClass('active');
$(this).parents('tr').addClass('active');
});
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.