javascript - Bind event to div but 'not' inner div -
this question has answer here:
i have set of divs looks this
<div class="videothumbnail" data-videoid="4"> <div class="video"><img src="some/url" alt="video thumbnail preview"/></div> <div class="title">i'm video</div> <div class="download"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span></div> </div> then binding event videothumbnail class. function works fine , need bind event when download clicked. 2 bind events this.
//bind selecting thumbnail change video $( '.videothumbnail' ).not( '.download' ).on( 'click', function ( t ) { alert('you doing thumbnail stuff'); } ); //bind download on litle download icon $( '.download' ).on( 'click', function ( t ) { alert('you want download this'); } ); i first bind event on videothumbnail happen when it's not selecting download within it. unfortunately whenever press download icon both functions execute. how can bind first event videothumbnail without binding download that's inside of it?
you need use event.stoppropagation
code
$('.download').on('click', function(event){ event.stoppropagation(); // click code.. });
Comments
Post a Comment