jQuery check all not working on checkboxes
<p>I'm writing some code that will allow the following:</p>

<p>1.) If a user checks a checkbox it will change the parent <code>&lt;tr&gt;</code> to have a class of selected (this can also be unchecked and remove the class)</p>

<p>2.) Any checkboxes that are already checked will have the class added on document load</p>

<p>3.) If a user checks the #checkall input then all inputs will become checked and add the class of selected (if checked again then it will unselect all and remove the class)</p>

<p>This is the code I have so far:</p>

<pre><code>$("table input[name=choose]:checked").each(function()
    {
        $(this).closest("tr").addClass("selected");
    });

    $("table input[name=choose]").live("change", function()
    {
        $(this).closest("tr").toggleClass("selected");
    });

    if ($('#checkall:checked') ==  true)
    {
        $('#checkall').live("click", function()
        {
            $('table input[name=choose]').attr('checked', false);
            $('table input[name=choose]').closest("tr").toggleClass("selected");              
        });
    }
    else
    {
        $('#checkall').live("click", function()
        {
            $('table input[name=choose]').attr('checked', true);
            $('table input[name=choose]').closest("tr").toggleClass("selected");
        });
    }
</code></pre>

<p>The first two work fine but number 3 doesn't uncheck the checkboxes... Any ideas why? But the class part works fine??</p>

<p>Thanks</p>
