basically I am looking for a way to slideDown a div in jquery after the page has loaded. I've found few ways how to do it with a click button like this but less luck in finding a solution to load it without a button. I've tried to work with this previous topic but no luck.
Asked
Active
Viewed 2,981 times
0
-
have u posted the link to the wrong fiddle? it is having nor slide down element in it – Ninja Jan 20 '12 at 19:32
-
you want to run code after the page loads, is that right? – Marcelo Diniz Jan 20 '12 at 19:34
-
of course id did paste in the wrong one...sorry. Yes after the page loads. – Michał Korzeniowski Jan 20 '12 at 19:39
-
the accepted answer is technically incorrect. Please edit the question to state 'after the dom loads' and not 'after the page loads' – Marcelo Diniz Jan 20 '12 at 19:47
-
so this would slide the div after the page loads? "$(window).load(function() { " – Michał Korzeniowski Jan 20 '12 at 19:53
-
yes, after the dom is loaded and all the elements are downloaded. This link explains the difference http://api.jquery.com/ready/ – Marcelo Diniz Jan 20 '12 at 19:59
3 Answers
0
this solution http://jsfiddle.net/XqqtN/ is doing it on load
for your code you will need to wrap it in
$(function(){
... code ...
});

eiu165
- 6,101
- 10
- 41
- 59
0
$(document).ready(function() {
$('#div').slideDown();
}

Kyle Macey
- 8,074
- 2
- 38
- 78
-
`.ready` is triggered when the dom is ready, not when the page is loaded. – Marcelo Diniz Jan 20 '12 at 19:38
-
Have u checked this works? To me, the entire point of this post he gave the link for was that this does not work: http://stackoverflow.com/questions/2647137/how-to-jquery-slidedown-once-page-has-already-been-loaded – Ninja Jan 20 '12 at 19:39
0
One thing you can do is to trigger the click event in the JS, so that the div slide down works on document ready, without the user having to press the buttton. code here: http://jsfiddle.net/7VpPu/
You can set the button element opacity to 0, so that it remains invisible to user

Ninja
- 5,082
- 6
- 37
- 59