Mike Alsup wrote:

This should work:

$(document).ready(function() {
   $("[EMAIL PROTECTED]'section']").click(function(){
       $(this).css('background', this.checked ? 'red' : '');
   })
});


On top of that I'd like to suggest a better separation of the presentational aspect. It's the responsibility of CSS to make things look somehow, thus I would expect that information in a style sheet:

$(document).ready(function() {
    $("[EMAIL PROTECTED]'section']").click(function(){
        $(this)[this.checked ? 'addClass' : 'removeClass']('checked');
    });
});


input.checked {
    background: red;
}




--Klaus

Reply via email to