JQuery 循环暂停
我希望将幻灯片暂停大约 4 秒钟,并且在恢复之前不显示幻灯片。这可能吗?我尝试使用以下代码自己执行此操作,但它似乎不起作用。
$(document).ready(function () {
$('#homeSlideshowWrapper').cycle({
fx: 'fade',
timeout: 4000,
after: onBefore
});
function onBefore() {
$('#homeSlideshowWrapper').cycle('pause')
$('#homeSlideshowWrapper').delay(5000).cycle('resume')
} });
谢谢卢克
·斯特拉顿
I wish to pause the slideshow for about 4 seconds with no slide displayed before resuming. Is this possible? I have tried to do this myself with the following code but it does not seem to work.
$(document).ready(function () {
$('#homeSlideshowWrapper').cycle({
fx: 'fade',
timeout: 4000,
after: onBefore
});
function onBefore() {
$('#homeSlideshowWrapper').cycle('pause')
$('#homeSlideshowWrapper').delay(5000).cycle('resume')
} });
Thanks
Luke Stratton
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,onbefore 函数中的两个命令都缺少分号。其次,您在 document.ready 内部声明了一个函数,它实际上不应该出现在任何函数中。第三,您应该使用 .css(display, 'none') 在暂停时隐藏幻灯片(如果这就是您在恢复之前不显示幻灯片的意思)。如果不去掉 hide() 和 show() 处的行结束)。试试这个:
这可能并不完美,但应该会好一点。
First of all, you are missing semicolons on both commands in the onbefore function. Second of all, you are declaring a function inside of the document.ready, where it really should not be in any function. Third is that you should use .css(display, 'none') to hide the slideshow while it's paused (if that's what you mean by no slide displayed before resuming. If not get rid of the hide() and show() at the line ends). Try this:
That may not be perfect, but should be a bit better.
可以用setTimeout来实现吗?
例如
Can you achieve this with setTimeout?
E.g.