click event being fired twice - jquery
Posted
by
maxp
on Stack Overflow
See other posts from Stack Overflow
or by maxp
Published on 2011-01-10T17:43:45Z
Indexed on
2011/01/10
17:53 UTC
Read the original article
Hit count: 133
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?
© Stack Overflow or respective owner