event.preventDefault()
阻止默认事件
event.stopPropagation()
阻止冒泡
<div class="outer">
<div class=”inner“><a link="#">点击跳转</div>
</div>
$(".outer ").click(function(e){
alert(1)
})
//页面打印1,跳转
$(".outer a").click(function(e){
e.stopPropagation()
})
$(".outer ").click(function(e){
alert(1)
})
//页面不会打印1,会跳转
$(".outer a").click(function(e){
e.preventDefalt()
})
$(".outer ").click(function(e){
alert(1)
})
//页面打印1,不会跳转
$(".outer a").click(function(e){
e.preventDefalt()
e.stopPropagation()
})
$(".outer ").click(function(e){
alert(1)
})
//页面不会打印1,不会跳转