onClick function returns undefined
<p>For some reason, the following code does not work properly:</p>

<pre><code>&lt;input onclick="$(function(){ alert($(this).attr('checked')); })" name="step1[agree]" id="step1_agree" value="1" type="checkbox"&gt;
</code></pre>

<p>It alerts with <code>undefined</code>. I have also tried doing something like this:</p>

<pre><code>onclick="$(function(){ var chk=$(this); alert(chk.attr('id')); })"
</code></pre>

<p>... but ends up with the same result. What am I doing wrong and how can I fix this?</p>
