The "toggle()" function is used to hide and show items, nothing to do
with clicking or changing of state.

http://docs.jquery.com/Effects/toggle

What you want is something like:

$('[EMAIL PROTECTED]').click(
    function() {
      if ( this.checked )
        
$(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000);
      else
        
$(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000);
    }
);

Karl Rudd

On Thu, Apr 3, 2008 at 12:41 PM, Bruce MacKay <[EMAIL PROTECTED]> wrote:
>
>  Hello folks,
>
>  I have a table of data, with each row containing a checkbox.  What I want
> users to be able to do is tick the box of each row of data they want to
> delete (and after ticking, they will submit the form etc etc.
>
>  As a visual aid, I want to alter the background colour of the row - and if
> they untick a selection, to reverse that background colour change.
>
>  My code as follows achieves the background colour toggle, but the
> checkboxes are neither checked or unchecked.
>
>  I'd appreciate someone pointing out my error?
>
>
>  $('[EMAIL PROTECTED]').toggle(
>      function() {
>        $(this).attr('checked',true);
>
> $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#FFF'},1000);
>      },
>      function() {
>        $(this).attr('checked',false);
>
> $(this).parents('tr').animate({backgroundColor:'#9C3'},2000).animate({backgroundColor:'#E0F88F'},1000);
>      }
>  );
>
>  Thanks
>  Bruce

Reply via email to