Grr, I just finished typing my answer to this question before it was deleted. Are you going to remove this too?
I created a sample file to validate your script, and it worked as I expected. I have included it below for your reference. At the same time, I suggest removing any code that is not related to a specific functionality that you are trying to solve during the test in order to exclude the absence of peripheral problems with other code. Also, be sure to create a view> source to make sure your table really has that identifier, and that your checkboxes and HTML are displayed correctly and correctly. If you break the HTML, your jQuery will not work.
Here is an example file that I used. Which browser are you testing?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Untitled</title> <script type="text/javascript" src="shared-scripts/jquery-1.2.4b.js"></script> <style type="text/css"> .highlight { background-color: yellow; } </style> <script type="text/javascript"> <!-- $(document).ready(function(){ $("#Table input").click(function() { if ($(this).attr("checked") == true) { $(this).parent().parent().addClass("highlight"); } else { $(this).parent().parent().removeClass("highlight"); } }); }); </script> </head> <body> <form name="f"> <table id="Table" border="1"><tr> <td><input type="checkbox" name="cb1" id="cb1" value="y" /></td> <td>Click me</td> </tr><tr> <td><input type="checkbox" name="cb2" id="cb2" value="y" /></td> <td>Click me</td> </tr><tr> <td><input type="checkbox" name="cb3" id="cb3" value="y" /></td> <td>Click me</td> </tr></table> </form> </body> </html>
source share