Reputation: 533
I'm not a programmer, but I use the code below to scroll the page to the top.
How can I adapt it to make a scroll down?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<a class="btnMedio" href="javascript:;">
<img src="http://desmond.imageshack.us/Himg41/scaled.php?server=41&filename=deixeseuemail.png&res=landing"/>
</a>
<script>
$('.btnMedio').click(function(){
$('html, body').animate({scrollTop:1000},'50');
});
</script>
Upvotes: 26
Views: 143912
Reputation: 51
If you want to scroll down to the div (id="div1"). Then you can use this code.
$('html, body').animate({
scrollTop: $("#div1").offset().top
}, 1500);
Upvotes: 4
Reputation: 7055
This can be used in to solve this problem
<div id='scrol'></div>
in javascript use this
jQuery("div#scrol").scrollTop(jQuery("div#scrol")[0].scrollHeight);
Upvotes: 9
Reputation: 1
jQuery(function ($) {
$('li#linkss').find('a').on('click', function (e) {
var
link_href = $(this).attr('href')
, $linkElem = $(link_href)
, $linkElem_scroll = $linkElem.get(0) && $linkElem.position().top - 115;
$('html, body')
.animate({
scrollTop: $linkElem_scroll
}, 'slow');
e.preventDefault();
});
});
Upvotes: 0
Reputation: 144729
$('.btnMedio').click(function(event) {
// Preventing default action of the event
event.preventDefault();
// Getting the height of the document
var n = $(document).height();
$('html, body').animate({ scrollTop: n }, 50);
// | |
// | --- duration (milliseconds)
// ---- distance from the top
});
Upvotes: 56
Reputation: 4339
I mostly use following code to scroll down
$('html, body').animate({ scrollTop: $(SELECTOR).offset().top - 50 }, 'slow');
Upvotes: 10
Reputation: 437
Try This:
window.scrollBy(0,180); // horizontal and vertical scroll increments
Upvotes: 24