2011-05-31 171 views
0

即时消息试图完成的是在页面加载时的淡入淡出效果,然后一个很好的淡出效果,并在每个单独项目的鼠标悬停效果,你可以看到我在这里工作:http://themes.thefragilemachine.com/themachine_v4/JQuery淡入,使用鼠标滚轮淡入淡出效果问题

我知道这可以使用子调用完成吗?我只是不知道该怎么做,但基本上我想有一个班我可以申请到真正的任何股利,并使用它的效果,对于鼠标至少,任何帮助将是惊人的!谢谢!

这里是我的jQuery代码:

<script type="text/javascript"> 
    $(document).ready(function() { 

     window.onload = function() { $('.test1').hide().fadeIn(1500); }; 

     $('.test1').mouseover(function() { 
      $('.test1').fadeOut('fast').fadeIn('slow'); 
     }); 
    }); 
</script> 

这里是我的html代码:

<div class="featured-pitem g_4 test1"></div> 
<div class="featured-pitem g_4 test1"></div> 
<div class="featured-pitem g_4 test1"></div> 
<div class="featured-pitem g_4 test1"></div> 
<div class="featured-pitem g_4 test1"></div> 
<div class="featured-pitem g_4 test1"></div> 

回答

0

你在找这个吧?

$('.test1').mouseover(function() { 
    $(this).fadeOut('fast').fadeIn('slow'); 
}); 

使用$(this)应该应用衰落效应当前元素仅使用$('.test1')适用的影响,以与一类test1所有元素。

+0

摇滚!谢谢!那工程 – 2011-05-31 17:45:50

+0

真棒!谢谢!快速的问题,有没有办法将$(this)调用应用到页面渐变到每个项目?以便每个项目都按顺序而不是一次全部消失? – 2011-05-31 17:56:20

0

您在document.ready中分配“window.onload”侦听器。但是document.ready在window.onload之后触发,所以你的代码没有任何影响。在任何情况下,当窗口被加载时,没有加载DOM,所以没有要选择的元素。你应该重写它是这样的:

$(document).ready(function() { 

$('.test1').hide().fadeIn(1500); 
$('.test1').mouseover(function() { $('.test1').fadeOut('fast').fadeIn('slow'); }); 


}); 

顺便说一句,有一个很好的快捷方式的jQuery的$(document)。就绪(...)等于$(...),只要把在功能$(...)调用

0
<script type="text/javascript"> 
$(document).ready(function() { 

    $('.test1').hide().fadeIn(1500); 

    $('.test1').mouseover(function() { $(this).fadeOut('fast').fadeIn('slow'); }); 


}); 
</script> 





衰落序列,就可以使用这样的事情:

<script type="text/javascript"> 

$(文件)。就绪(函数(){

$('.test1').hide(); 

$('.test1').each(function(i){ 
     var timing = i*2+60; 
     $(this).delay(timing).fadeIn(1500); 
}); 





$('.test1').mouseover(function() { $(this).fadeOut('fast').fadeIn('slow'); }); 

});

+0

真棒!谢谢!快速的问题,有没有办法将$(this)调用应用到页面渐变到每个项目?以便每个项目都按顺序而不是一次全部消失? – 2011-05-31 17:55:39