默认事件~
默认事件的阻止
简单的默认事件阻止
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a onclick="fn(event)" href="http://www.baidu.com">123</a>
<script>
//js和html是两门不同的语言,分开运行
function fn(e){
var e=e||window.event;
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue=false;//ie阻止默认事件
}
console.log(e);
}
</script>
</body>
</html>

浙公网安备 33010602011771号