在Scroll jQuery上执行函数 [英] Execute function on Scroll jQuery
本文介绍了在Scroll jQuery上执行函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我误解了scroll()函数。如果主窗口向上或向下滚动,我希望如果面板打开则执行一个功能。这是我的代码什么都不做。
I'm misunderstanding the scroll() function. I'm wishing to if a panel is open execute a function if the main window is scrolled up or down. This is my code that does nothing.
if('#specsallA:visible').scroll(function(){
$('#specsbar').animate({
width:'190px'
}, '500'); $('.products').animate({
width:'168px'
}, '500'); $('#specsallA').hide(); $('#specsall').show();
});
任何想法,
Marvelous
Marvellous
推荐答案
轻微的误解。最简单的方法是将你的if()测试放在事件回调中
A slight misunderstanding. Easiest way is to put your if() test inside the event callback
$(window).scroll(function() {
if ($('#specsallA').is(':visible')) {
// do your special stuff here
}
});
这篇关于在Scroll jQuery上执行函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文