需要使用处理程序连续执行
我目前有两个链接,两个箭头,一个向上,另一个向下,我想要它做的是滚动位于
中的内容,该内容被 < 屏蔽代码>。
换句话说:
<div id="scroller">
<div id="scroller1">...</div>
</div>
我的代码如下所示:
$("a.mouseover_up").mousedown(function () {
var currentMargin = $("#scroller1").css("marginTop");
currentMargin = currentMargin.replace("px","");
$("#scroller1").animate({"marginTop": (currentMargin - 5) + "px"});
return false;
});
现在发生的情况是,它正确执行 animate
,但在 5px 后停止滚动。只要用户在上面的链接上按住鼠标按钮,我就希望它有动画效果。
任何帮助表示赞赏。谢谢。
I currently have to two links, two arrows one pointing up and the other down, what I want it to do is scroll content located in <div id="scroller1">
which is masked by <div id="scroller">
.
In other words:
<div id="scroller">
<div id="scroller1">...</div>
</div>
My code looks like this:
$("a.mouseover_up").mousedown(function () {
var currentMargin = $("#scroller1").css("marginTop");
currentMargin = currentMargin.replace("px","");
$("#scroller1").animate({"marginTop": (currentMargin - 5) + "px"});
return false;
});
What happens now is, it executes the animate
properly, but stops scrolling after 5px. I want it to animate as long as user is holding the mouse button down on the link above.
Any help is appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这样的事情会起作用:
查看这个演示:http://jsfiddle.net/J9QNZ/2
I believe something like this would work:
See this demo: http://jsfiddle.net/J9QNZ/2