Klaus thanks it works!

Since you made a great suggestion, here's the thing

it's like this

<ul>
       <li><input type="radio" name="section" value="">bla bla</li>
       <li><input type="radio" name="section" value="">bla bla 2</li>
</ul>

i'd actually like to change the background of the list item, so how do
i append the class to the appropriate list item?

On Jun 21, 6:47 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> 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