我在谷歌上搜索了解决我的问题的方法,但是我不明白为什么我写的代码对别人都有效,但对我无效。
我写的是这个:
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
function scrollTo() {
$('html, body').animate({ scrollTop: $('#div_id').offset().top }, 'slow');
return false;
}
</script>
<style type="text/css">
.uno {
height: 1000px;
background: #808080;
}
.due {
margin-top: 300px;
height: 500px;
background: #ff00ff;
}
</style>
</head>
<body>
<div class="uno" onclick="scrollTo()">
Clicca
</div>
<div class="due" id="div_id"></div>
</body>