Name: Anonymous 2013-01-08 5:56
Hey /prog/,
Very noob starting programmer here.
I have a set of divs that fade out and fade in when their respective menulink is clicked. The first div should load automatically on pageload without any fades, and if no content is loaded there should only be a fade in effect.
Now I'm getting all of this done except for the instant load of the first div. When I load the page, no content is present, a fade out occurs and then the first div automatically fades in.
How can I make sure the first div I have automatically loads without any fades?
Current code:
$(document).ready(function() {
$('a').bind("click", function(){
$('a').removeClass("actief");
$(this).addClass("actief");
var fade = $(this);
if($('#content').html()){
$(this).addClass("actief");
$('#content').stop().fadeTo(500,0,function(){
$('#content').html("").css('opacity', 0);
fade.next().clone().appendTo('#content');
$('#content').stop().fadeTo(500,1);
});
}
else{
$('#content').css('opacity', 0);
fade.next().clone().appendTo('#content');
$('#content').stop().fadeTo(500,1);
}
});
$('a:first').trigger('click');
});
Very noob starting programmer here.
I have a set of divs that fade out and fade in when their respective menulink is clicked. The first div should load automatically on pageload without any fades, and if no content is loaded there should only be a fade in effect.
Now I'm getting all of this done except for the instant load of the first div. When I load the page, no content is present, a fade out occurs and then the first div automatically fades in.
How can I make sure the first div I have automatically loads without any fades?
Current code:
$(document).ready(function() {
$('a').bind("click", function(){
$('a').removeClass("actief");
$(this).addClass("actief");
var fade = $(this);
if($('#content').html()){
$(this).addClass("actief");
$('#content').stop().fadeTo(500,0,function(){
$('#content').html("").css('opacity', 0);
fade.next().clone().appendTo('#content');
$('#content').stop().fadeTo(500,1);
});
}
else{
$('#content').css('opacity', 0);
fade.next().clone().appendTo('#content');
$('#content').stop().fadeTo(500,1);
}
});
$('a:first').trigger('click');
});