<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#a1{
width:50px;height:30px;
border:1px solid #555;
color:#555;
border-radius: 3px;
font-size: 14px;
text-decoration: none;
padding: 5px;
}
</style>
</head>
<body>
<a id="a1" href="#top"> click me </a>
<script>
a1.onclick=function(e){
alert("滚!")
e.preventDefault();
// 阻止 默认行为
}
</script>
</body>
</html>
(day05—05)阻止默认行为
猜你喜欢
转载自blog.csdn.net/qq_43459224/article/details/90083398
今日推荐
周排行