<!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)阻止默认行为
最新推荐文章于 2024-03-25 01:59:57 发布