Optimize jQuery selectors code I have this fiddle http://jsfiddle.net/L7zuT/ where I'm working on a small part of a big event program. The functionality is ok, the part of the problem would be the large JavaScript lines needed with the full event program. Is there any way to implement it with DRY (don't repeat yourself) or a better approach for a simpler way? 


&lt;table cellspacing="0" cellpadding="0" border="1"&gt;

  &lt;tr&gt;
    &lt;td&gt;13:00-14:30&lt;/td&gt;
    &lt;td rowspan="2"&gt;&lt;label for="date_main01"&gt;18.AAL Solution Deployment Seminar&lt;/label&gt;&lt;/td&gt;
      &lt;td rowspan="2"&gt;&lt;label for="date_main02"&gt;9. Results of the AALIANCE Network: Roadmap and more&lt;/label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;label for="date_sub03"&gt;7. From    actimetry to ADL ,in the framework of remote medical monitoring of elderly    from living labs to the nursing home&lt;/label&gt;&lt;/td&gt;
      &lt;td rowspan="2"&gt;&lt;label for="date_main05"&gt;8. Interoperability APIs and LivingLabs for AAL&lt;/label&gt;&lt;/td&gt;
      &lt;td rowspan="2"&gt;&lt;label for="date_main06"&gt;10. Large scale deployment of AAL solutions based on Open    Platform: Challenge and perspectives&lt;/label&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;14:30-16:00&lt;/td&gt;
      &lt;td&gt;&lt;label for="date_sub04"&gt;1.    User Forum and workshop for exergames in AAL&lt;/label&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;16:00-17.30&lt;/td&gt;
        &lt;td&gt;&lt;label for="date_last07"&gt;19.Deployment event - matchmaking session&lt;/label&gt;&lt;/td&gt;
        &lt;td colspan="5"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;input id="date_main01" name="date_main01" type="radio" value="01" /&gt;
&lt;input id="date_main02" name="date_main01" type="radio" value="02" /&gt;
&lt;input id="date_sub03" name="date_sub01" type="radio" value="03" /&gt;
&lt;input id="date_sub04" name="date_sub02" type="radio" value="04" /&gt;
&lt;input id="date_main05" name="date_main01" type="radio" value="05" /&gt;
&lt;input id="date_main06" name="date_main01" type="radio" value="06" /&gt;
&lt;input id="date_last07" name="date_last01" type="radio" value="07" /&gt;


CSS


tr {
    height: 1px;
}
td{
    height: 100%;
}
label{
    display: block; 
    min-height: 100%; /* for the latest browsers which support min-height */
    height: auto !important; /* for newer IE versions */
    height: 100%; /* the only height-related attribute that IE6 does not ignore  */
}
label:hover {
    cursor:pointer;
}


JS

$(document).ready(function(){
    $("input[name='date_main01']").click(function() {
        var test = $(this).val();
        $("input[name='date_sub01']").prop('checked', false);
        $("input[name='date_sub02']").prop('checked', false);
        $("label[for*='date_main']").css("background", "none");
        $("label[for*='date_sub']").css("background", "none");
        $("label[for='date_main"+test+"']").css("background-color", "yellow");            
    });
    $("input[name='date_sub01']").click(function() {
        var test = $(this).val();
        $("input[name$='date_main01']").prop('checked', false);
        $("label[for*='date_main']").css("background", "none");
        $("label[for='date_sub"+test+"']").css("background-color", "yellow");            
    });
    $("input[name='date_sub02']").click(function() {
        var test = $(this).val();
        $("input[name$='date_main01']").prop('checked', false);
        $("label[for*='date_main']").css("background", "none");
        $("label[for='date_sub"+test+"']").css("background-color", "yellow");            
    });
        $("input[name='date_last01']").click(function() {
        var test = $(this).val();
        $("label[for='date_last"+test+"']").css("background-color", "yellow");            
    }); 
});
$("input[name='date_sub01']").prop('checked', false);
 $("input[name='date_sub02']").prop('checked', false);


Can be turned into:

$("input[name='date_sub01'], input[name='date_sub02']").prop('checked', false);


Also if you assign the selectors to a variable your code will be much faster:

var sub_01 = $("input[name='date_sub01']")


You never need to use the method .val().

If you do:

var test = this.value;


You will get the same results without accessing jQuery.

Since you are using background:none alot, you can keep it in an object:

noneBackground: {"background":"none"}


and pass it as an argument

  $("label[for*='date_main']").css(noneBackground);