How to make a script that slides down content AFTER whole page is loaded.
For example I click a link like index.php?category=1
. After that page is loaded and I need to slide down page to specific ID
.
How to do that?
How to make a script that slides down content AFTER whole page is loaded.
For example I click a link like index.php?category=1
. After that page is loaded and I need to slide down page to specific ID
.
How to do that?
Use an anchor.
Modify your URL to include an anchor:
index.php?category=1#targetElement
Then add an ID to the element that should come into focus when the page loads:
<div id="targetElement">
If you have an anchor on your page like <div id="anchor">
, you can use this script that while slide the page to the anchor position when the page is loaded :
$(function() {
var anchorPos= $('#anchor').offset().top;
$('html, body').animate({scrollTop:anchorPos}, 'slow');
});
EDIT : Fiddle example of this working solution
do you need to animate the slide down of the page or you just need the functionality?
if no, cant you just use <a name="anchor"></a>
somewhere you want to scroll the page into?
besides, that's what its for right?
now make it slide down, you can use index.php?category=1#anchor
but if you need it to be animated, you need to add these code as specified on another link here in stackoverflow Simple jQuery scroll to anchor up or down the page...?
var aTag = $("a[name='anchor']");
$('html,body').animate({scrollTop: aTag.offset().top},'slow');