这是 jsfiddle 链接:http://jsfiddle.net/NKgG9/
我基本上希望那些粉色的框在页面加载时像往常一样显示,但是当用户向下滚动页面时,我希望它们淡出并消失。当用户向上滚动到他们的位置或浏览器窗口的顶部时,我希望那些粉色的框再次淡入。我对 JS 无能为力,所以需要一些帮助来完成这个任务。
感谢您的所有帮助。
感谢您的所有帮助。
非常简单的例子:http://jsfiddle.net/a4FM9/2/
var divs = $('.social, .title');
$(window).scroll(function(){
if($(window).scrollTop() <10 ){
divs.stop(true,true).fadeIn("fast");
} else {
divs.stop(true,true).fadeOut("fast");
}
});
$(document).ready ..
函数中添加$(window).trigger('scroll');
。 - Cheery$(function(){
var targets = $(".title, .social");
if($(window).scrollTop() > 10){
targets.hide();
}
$(window).scroll(function(){
var pos = $(window).scrollTop();
if(pos > 10){
targets.stop(true, true).fadeOut("fast" );
} else {
targets.stop(true, true).fadeIn("fast");
}
});
});