为什么event.stopPropagation();不能在交换机上工作? [英] why event.stopPropagation(); not working on switch?
问题描述
能否请您告诉我为什么event.stopPropagation();在开关上不起作用?
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.
当我更改开关时,它打印开关控制台.但是,当我单击单击区域时,它会打印行事件(控制台).为什么 ? http://jsfiddle.net/k7zJ4/
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();
});
});
推荐答案
工作示例: http://jsfiddle. net/pT2bU/1/
$(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();
});
});
我已将您的 click 事件替换为名为 vclick 的jQuery Mobile版本,该事件不会受到事件传播的影响,并且可在台式机和移动浏览器上使用.
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.
这篇关于为什么event.stopPropagation();不能在交换机上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!