Jquery 事件冒泡、元素的默认行为的阻止、获取事件类型、触发事件

$(function(){
// 事件冒泡
$('').bind("click",function(event){
//事件内容
//停止事件冒泡
event.stopPropagation();
})
// 默认行为
$("#sub").bind("click",function(event){
//事件内容
//阻止默认行为
event.preventDefault();

})
$("a").click(function(event){
console.log(event.type); //获取事件类型
return false; //阻止链接跳转
})
$("a").click(function(){
console.log(event.target.href); //获取触发事件的href属性值
return false; //阻止链接跳转
})
})
posted @ 2017-08-14 09:11  ThisCall  阅读(320)  评论(0编辑  收藏  举报