|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Javascript - Basic jquery question
I'm looking to modify this code in order to have my content auto fade in after about 1-2 seconds. currently, it only fades in when you move the mouse cursor over the content.
Code:
$(document).ready(function(){ $(".latest_img").fadeTo("slow", 0.3); $(".latest_img").hover(function(){ $(this).fadeTo("slow", 1.0); },function(){ $(this).fadeTo("slow", 0.3); }); });
thanks for the help |
|
#2
|
|||
|
|||
|
you just remove most of the hover code and put the fade in inside of a function. then use setTimeout to start that after however long you want to wait before fade in.
Code:
function startFade(){
$(".latest_img").fadeTo("slow", 1.0);
}
$(document).ready(function(){
$(".latest_img").fadeTo("slow", 0.3);
setTimeout('startFade()', 2000);
});
|
|
#3
|
|||
|
|||
|
thanks a bunch llama.
one minor issue is that it still is first visible then fades, and then after 2 seconds it fades back like it should. what line of code would ensure the content is not visible at all when refreshing the page? until it fades into view that is. thanks again |
|
#4
|
|||
|
|||
|
i tried to add a 'hide' variable to fix it, but it doesn't work hehe
Code:
function startFade(){
$(".latest_img").fadeTo("slow", 1.0);
}
$(document).ready(function(){
$(".lastest_img").hide();
setTimeout('startFade()', 2000);
});
|
|
#5
|
|||
|
|||
|
you could also add to the css to hide it. that would probably work the best. but what you did should work as well. or you could use the previous code and change the "slow" to either a faster option or use the milliseconds option to fade instantly.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Javascript - Basic jquery question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|