【发布时间】:2014-08-01 05:30:29
【问题描述】:
我在 google 上搜索了我的问题的解决方案,但我不明白为什么我编写的代码适用于所有人,但不适用于我。
我写了这个:
<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>
【问题讨论】:
-
你是否包含了 jquery 库
-
为什么不在 SO 上发布之前检查控制台? :)
标签: javascript jquery html css scroll