why the checkall code doesn't work?
<p>html code:</p>

<pre><code>&lt;div&gt;

        &lt;input type="checkbox" onclick="selectAll(this);" /&gt;select all&lt;br/&gt;
        &lt;input type="checkbox"  /&gt;&lt;br/&gt;
        &lt;input type="checkbox"  /&gt;&lt;br/&gt;
        &lt;input type="checkbox"  /&gt;&lt;br/&gt;
        &lt;input type="checkbox"  /&gt;&lt;br/&gt;
        &lt;input type="checkbox"  /&gt;&lt;br/&gt;
        &lt;input type="checkbox"  /&gt;&lt;br/&gt;
&lt;/div&gt;
</code></pre>

<p>jquery code:</p>

<pre><code>    $(document).ready(function(){
  function selectAll(checkbox){
    alert("test");
    $("input[type=checkbox]").attr('checked',$(checkbox).attr('checked'));
    }
    });
</code></pre>

<p>why the select and unselect all doesn't work. when i put the alert statement to test what's wrong with the code. the alert also doesn't work. </p>

<p><strong>i want to know why my code doesn't work?</strong></p>
