click event being fired twice - jquery
- by maxp
I have the following simplified html:
<div class="foo" style="width:200px; height:200px;">
<input type="checkbox" />
</div>
<script type="text/javascript">
$('.foo').click(function(){$(this).find('input:checkbox')[0].click();});
</script>
Clicking the 200x200 div 'foo' works well, and raises the click event for the checkbox inside it.
However when I exactly click the checkbox itself, it fires its 'normal' event, plus the jquery bound event above, meaning the checkbox checks itself, then unchecks itself again.
Is there a tidy way to prevent this from happening?