问题
can you please tell me why event.stopPropagation(); not working on switch ?
I click on on click it print the row event(console) .It should print only switch console.
when I change the switch it print switch console.But when i click on click area it print row event(console). why ? http://jsfiddle.net/k7zJ4/
$(function(){
$('#testSuitConfiguration').click(function () {
console.log('pp')
});
$( ".selectSequenc_h" ).on( "change", function(event, ui) {
//alert('pp')
console.log('==')
event.stopPropagation();
});
});
回答1:
Working example: http://jsfiddle.net/pT2bU/1/
JavaScript
$(document).on('pageinit', '#home', function(){
$(document).on('vclick','#testSuitConfiguration',function () {
console.log('pp')
});
$(document).on( "slidestop", ".selectSequence_h" ,function( event, ui ) {
console.log('==');
event.stopPropagation();
event.stopImmediatePropagation();
});
});
I have replaced your click event with jQuery Mobile version called vclick, this one don't suffer from event propagation and it works on desktop and mobile browsers.
来源:https://stackoverflow.com/questions/23702253/why-event-stoppropagation-not-working-on-switch