[英].fadeIn() not working properly
I'm trying to have a quote that fades in when you scroll all the way the bottom to the page. 当您一直滚动到页面底部时,我试图提供一个淡入淡出的报价。 I have this little bit of inline jquery (it's so little I can't really justify making a new file), but it doesn't seem to work.
我有一些内联jquery(实在太少了,我不能真正证明创建一个新文件是合理的),但是它似乎不起作用。 The quote keeps an opacity of 0:
引号的不透明度保持为0:
$(document).ready(function(){
if($(document).height()-$(window).height() < $(document).scrollTop() + 20) {
$('#quote').fadeIn('fast',1);
}
else {
}
});
when I remove the if/else statement, the fadeIn still doesn't work, so that's why I'm confident saying that the issue lies with something else 当我删除if / else语句时,fadeIn仍然不起作用,所以这就是为什么我有信心地说问题出在其他方面
Thanks so much, 非常感谢,
also, heads up, I'm a total jQuery and js noob. 另外,抬头,我是一个jQuery和js noob。
Another thing is, that you actually don't listen to your website events, as scroll
, so code is executed when page is rendered and even if you scroll to the bottom, nothing happens. 另一件事是,您实际上并不像
scroll
那样监听网站事件,因此在呈现页面时将执行代码,即使滚动到底部也不会发生任何事情。
You can add event listener 您可以添加事件监听器
$('window').scroll(function() {
if($(document).height()-$(window).height() < $(document).scrollTop() + 20) {
$('#quote').fadeIn('fast');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.