I have one table, I want click td:first-child then change td:first- child's background color, when click the td-first-child , td background color change, but when I click other td:first-child, the removeClass not work correct,
anyone help ? thanks. my script: $(document).ready(function(){ $("div#mypoitable table#srch-result tbody tr").each( function(i) { $(this).find('td:first-child').bind("click", function() { $(this).siblings().removeClass('selected'); $(this).addClass('selected'); }) }) }) my css is <style type="text/css"> .selected {background:#33FF00} </style> my table is... <div id="mypoitable"> <table id="srch-result"> <tbody> <tr valign="top"> <td><a href="javascript:void(0)" id="4271"><span>A</span></a></td> <td><span class="del">D</span> | <span class="edit">E</span></td> </tr> <tr valign="top"> <td><a href="javascript:void(0)" id="4274"><span>B</span></a></td> <td><span class="del">D</span> | <span class="edit">E</span></td> </tr> <tr valign="top"> <td><a href="javascript:void(0)" id="4277"><span>C</span></a></td> <td><span class="del">D</span> | <span class="edit">E</span></td> </tr> </tbody> </table>