why event.stopPropagation(); not working on switch?

余生长醉 提交于 2019-12-16 18:05:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!