0

if i put event on parent then it also trigger on its child. how to stop trigger event on child

http://jsfiddle.net/nsoni/XLHKL/1/ is fiddle.

jquery:

$('.ful').on('click',function(){
    $('ul').show();
});
$('.ful').dblclick(function(){
    $('ul').hide();
});
$('.ful').mouseenter(function(e){
    $('.tip').show();
});
$('.ful').mouseout(function(e){
    $('.tip').hide();
});
$('ul').mouseenter(function(e){
    e.stopImmediatePropagation();
    $('.tip').hide();
});
  • You mean like this http://jsfiddle.net/XLHKL/2/? – Jack Jun 25 '14 at 17:45
  • Stop what on what? Be more specific. I am guessing you wanted `e.stopImmediatePropagation()` provided you add `e` to the mouseenter function – Huangism Jun 25 '14 at 17:47

1 Answers1

0

Unclear what you are asking, why can't people write good questions?

Events are propagated from the child to the parent, so your desire to stop the event chain from parent to child is not possible. Adding this stopped the dbl-click from collapsing the <ul>. Add the event argument to your events and call .stopPropagation();

$('.ful ul').dblclick(function(e){
   e.stopPropagation()
});
T McKeown
  • 12,971
  • 1
  • 25
  • 32