I am having some problem with this jQuery function. I have a table and onclick I need change the background to the tr's. And every tr has his own background color. This function change the background color but don't remove the class when the other tr is clicked.
HTML
<table class="steps_choose_pack" id="steps_domain_email"> <tr style="float:left;" id="tr_ess" class="essential_tr"> <td class="step2_tab_1" id="step2_domain_ess"><input type="radio" class="myRadio" name="field" value="essential" onclick= "showHide(['hide_steps_domain_01'],[],1);"></td> <td class="step2_tab_2"><strong>Essential:</strong>Domain</td> <td class="step2_tab_3">Qty: <select></select> </td> <td class="step2_tab_4">Unit Price:<strong> £28</strong> Annually</td> <td class="step2_tab_5"><a href=""><img class="question_mark" src="<?=base_url();?>images/question_mark.png"></a></td> </tr> <tr style="float:left;" id="tr_clss" class="classic_tr"> <td class="step2_tab_1" id="step2_domain_class"><input type="radio" class="myRadio" name="field" value="classic" onclick= "showHide(['hide_steps_domain02_01'],[],1);"></td> <td class="step2_tab_2"><strong>Classic:</strong>Domain & Business email</td> <td class="step2_tab_3">Qty: <select></select> </td> <td class="step2_tab_4">Unit Price:<strong> £52</strong> Annually</td> <td class="step2_tab_5"><a href=""><img class="question_mark" src="<?=base_url();?>images/question_mark.png"></a></td> </tr> <tr style="float:left;" id="tr_prm" class="premier_tr"> <td class="step2_tab_1" id="step2_domain_prm"><input type="radio" class="myRadio" name="field" value="premier"></td> <td class="step2_tab_2"><strong>Premier:</strong>Domain, business email & hosting</td> <td class="step2_tab_3">Qty: <select></select> </td> <td class="step2_tab_4">Unit Price:<strong> £279</strong> Annually</td> <td class="step2_tab_5"><a href=""><img class="question_mark" src="<?=base_url();?>images/question_mark.png"></a></td> </tr> </table> jQuery
$(document).ready(function(){ $('.steps_choose_pack').click(function() { $('tr.essential_tr').click( function() { $(this).siblings().removeClass('step_active_ess'); $(this).addClass('step_active_ess').removeClass("hover_table_type"); }); $('tr.classic_tr').click( function() { $(this).siblings().removeClass('step_active_class'); $(this).addClass('step_active_class').removeClass("hover_table_type"); }); $('tr.premier_tr').click( function() { $(this).siblings().removeClass('step_active_prm'); $(this).addClass('step_active_prm').removeClass("hover_table_type"); }); }); });
addClass()is working but thesiblings().removeClass()not?