页面就是这么简单!为啥a标签点击后滚动条会滚到页面顶端?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>jshint</title>
<style type="text/css">
body{
height:1500px;
}
#fill{
width:1000px;
height:1000px;
}
#a{
display: block;
width:300px;
height:30px;
border:5px solid black;
}
</style>
</head>
<body>
<div id="fill"></div>
<a href="" id="a">点我改变边框颜色</a>
<script type="text/javascript">
document.getElementById('a').onclick = function () {
this.style.cssText = 'border:5px solid red;'
};
</script>
</body>
</html>
智慧大石
相关分类