jQuery - Click event on div but not on checkbox in the div -


i'm trying setup click event on div, , event fire if div clicked anywhere except checkbox in div. if checkbox clicked, not want div's click event fire. setup click event on checkbox , returned false, stops div's click event, not allow checkbox become checked either. here's have now:

$('.thediv').click(function() {     // click event div, i'm slide toggling     $('.sub-div', $(this)).slidetoggle(); });  $('.checkboxinthediv').click(function() {     // stuff checkbox click, dont fire event above     return false; // returning false won't check/uncheck box when clicked }) 

instead of returning false, prevents default action, try stopping propagation.

$('.checkboxinthediv').click( function(e) {     e.stoppropagation();     ... other stuff...     return true; }); 

Comments

Popular posts from this blog

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -