1
2
3
4
5
6
|
< form id = "form1" runat = "server" > < div id = "divOne" onclick = "alert('我是最外层');" >
< div id = "divTwo" onclick = "alert('我是中间层!')" >
< a id = "hr_three" href = "http://www.websqq.org" mce_href = "http://www.websqq.org" onclick = "alert('我是最里层!')" >点击我</ a >
</ div >
</ div >
</ form >
|
/*方法一 return false */
如果是live方法的话就用return false
阻止本身的默认行为 如链接跳转 不跳转
1
2
3
4
5
|
$( function () {
$( "#hr_three" ).click( function (event) {
return false ;
}); }); |
/*方法二 event.stopPropagation */
不会阻止本身的默认行为 如链接跳转 会跳转
1
2
3
4
5
|
$( function () {
$( "#hr_three" ).click( function (event) {
event.stopPropagation(); }); });
|
本文转自Ansue 51CTO博客,原文链接:http://blog.51cto.com/ansue/1640196,如需转载请自行联系原作者