阻止默认行为
默认行为
不需要写js代码也能执行的一些行为,如:a标签点击就能跳转、form提交、鼠标右击 ....
阻止默认行为
阻止a标签\form标签也是3种办法
1.将a标签的href改了
2.在a标签的点击事件的最后,加上 return false
3.利用事件对象
document.querySelector("a").onclick = function(e){
var e = e || window.event;
// 阻止默认行为
e.preventDefault()
// // 在低版本ie中
// // e.returnValue = false
// console.log("呵呵");
//return false;
}

浙公网安备 33010602011771号