I've searched on google the solution to my problem, and I can't understand why the code I've written work for everyone, but not for me.
I've written this:
<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>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<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>
</html>
Try this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With