今天遇到乙個小問題:
li>
div>
div本身有click事件 然後li也有click事件
當觸發li標籤的click事件時,div的click事件也會觸發
因此加了e.stoppropagation();來阻止事件冒泡
但是firefox對e不相容,於是加了e = e||window.event;
e = e||window.event;
e.stoppropagation(); // 阻止事件冒泡
queryunsualmenu : function
(flag),
success : function
(data)else
}}else
}}else
}html+="";
html+="";
var open = $([html].join(''));
var close = $('《我的常用選單');
if($('.fixed-mymenu-open').length)
if($('.fixed-mymenu-close').length)
if(!flag),200);
}$('.fixed-mymenu-open').on('click','dt',function
(),200);
$('.fixed-mymenu-close').animate(,200);
});$('.added').on('click','.delete',function
(e));
$('.fixed-mymenu-open').on('click','.added',function
(e));
$('.fixed-mymenu-open').on('click','.add',function
(e));
$('.fixed-mymenu-close').on('click',function
(),200);
$('.fixed-mymenu-open').animate(,200);
});$('.fixed-mymenu-close').show();
}});
},
js阻止事件冒泡
比如上面這個頁面,分為三層 divone是第外層,divtwo中間層,hr three是最裡層 他們都有各自的click事件,最裡層a標籤還有href屬性。執行頁面,點選 點選我 會依次彈出 我是最裡層 我是中間層 我是最外層 這就是事件冒泡,本來我只點選id為hr three的標籤,但是確執行了三...
JS阻止事件冒泡,阻止預設事件
1 event.stoppropagation 阻止冒泡事件,不讓事件向documen上蔓延,但是預設事件任然會執行,當你掉用這個方法的時候,如果點選乙個鏈結,這個鏈結仍然會被開啟 2 event.preventdefault 阻止預設事件,呼叫此方法是,鏈結不會被開啟,但是會發生冒泡,冒泡會傳遞到...
js時間冒泡,阻止事件冒泡
首先解釋一下事件冒泡神什麼,在js中,假如在div中巢狀乙個div 如 style type text css box1 box2 box3 box4 box5 style body div id box1 div id box2 div id box3 div id box4 div id box...