jquery set div to toggle checkbox breaks clicking the checkbox itself -


i have check box:

<div class="outerdiv">    <div class="innerdiv">       <input type="checkbox" name="tie" value="tie">error in tie score<br>    </div> </div> 

i have jquery toggle checkbox:

$(document).ready(function() {    $('.outerdiv').click(function() {       if ($(this).find('input:checkbox').is(':checked')) {           $(this).find('input:checkbox').attr('checked',false);       } else {          $(this).find('input:checkbox').attr('checked',true);       }    }); }); 

this seems work, toggling checkbox when clicking on div. when click checkbox itself, nothing happens , not toggle.

you need stop propagation of event bubbling checkbox using event.stoppropagation()

$('input[type=checkbox]').click(function(e){     e.stoppropagation(); }); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -