Link to home
Start Free TrialLog in
Avatar of kgp43
kgp43Flag for Denmark

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:
$(document).ready(function() {
	$('input[type=radio]').change(function(){
		$('tr.active').removeClass('active');
		$(this).parents('tr').addClass('active');
	});
});

Open in new window


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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial