Smooth scroll using jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="">
<a href="#commment" class="paythis">Go To comments</a>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div id="commment" style="height:300px;width:300px;background:#d7d7d7; text-align:center;">
<h3>Comment Section</h3>
</div>
<script>
$('a.paythis').on('click',function(event){
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 5000, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
})
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="">
<a href="#commment" class="paythis">Go To comments</a>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div id="commment" style="height:300px;width:300px;background:#d7d7d7; text-align:center;">
<h3>Comment Section</h3>
</div>
<script>
$('a.paythis').on('click',function(event){
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 5000, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
})
</script>
0 comments: