Event binding ---- fail to stop bubbling

 

// .bb time to prevent failure under bubbling Click #aa
        $('#aa').on('click','.bb',function(event){
            console.log('aaa');
            event.stopPropagation();
        });
        $('#aa').on('click',function(){
            console.log('bbb');
        });

// should be because both are bound to the click event on #aa, it has triggered two clicks.
// If you want to prevent bubbling, you need to be bound by #aa .bb, prevent bubbling effect.

  

 

Guess you like

Origin www.cnblogs.com/lstrive/p/11134706.html