jQuery checking a checkbox and triggering javascript onclick event
<p>I'm trying to check a checkbox using jQuery and trigger the onclick event in the process.</p>

<p>Say I have a checkbox defined in html:</p>

<pre><code>&lt;input type="checkbox" value="checked" name="check1" onclick="alert(this.value);"&gt;
</code></pre>

<p>And I have a jQuery statement that is triggered in a function:</p>

<pre><code>$('input[name=check1]').attr('checked', true);
</code></pre>

<p>The result is the checkbox gets checked but the javascript onclick event is not triggered (hence no alert). But if I were to trigger the click even manually as such:</p>

<pre><code>$('input[name=check1]').attr('checked', true).trigger('click');
</code></pre>

<p>The result is the checkbox gets checked, javascript onclick event is triggered (and the value is correctly gotten) but then the checkbox gets unchecked after that.</p>

<p>Can anyone tell me how I can achieve what I'm trying to do?</p>
