jquery在ideltimeout上的进展
我确信有一些jQuery高手可以在5-6行中做到这一点。。。我的代码现在看起来更像意大利面条,所以我在这里问 我在一个带有jquery在ideltimeout上的进展,jquery,slideshow,Jquery,Slideshow,我确信有一些jQuery高手可以在5-6行中做到这一点。。。我的代码现在看起来更像意大利面条,所以我在这里问 我在一个带有按钮的页面上有大约20个sideshow 我喜欢在任何一秒钟内随机点击下一个sideshow 做这件事会让人分心,因为有20个杂耍节目同时自动推进 如何使用jQuery实现这一点 每隔1秒,选择任意类=下一步(按钮)并单击() -- 记录在案:那不行 <script type="text/JavaScript"> jQuery(document).ready(fu
按钮的页面上有大约20个sideshow
我喜欢在任何一秒钟内随机点击下一个sideshow
做这件事会让人分心,因为有20个杂耍节目同时自动推进
如何使用jQuery实现这一点
每隔1秒,选择任意类=下一步(按钮)并单击()
--
记录在案:那不行
<script type="text/JavaScript">
jQuery(document).ready(function($) {
setInterval( $('.next').click(), 1000 );
});
</script>
jQuery(文档).ready(函数($){
setInterval($('.next')。单击(),1000);
});
将函数传递给setInterval
jQuery(function($) {
var $next = $('.next'); // cache the selector for better performance
setInterval(function () {
$next.click();
}, 1000 );
});
如果要随机选择其中一个”。单击“下一步”
:
jQuery(function($) {
var $next = $('.next'),
n = $next.length;
setInterval(function () {
$next.eq(Math.floor(Math.random()*n)).click();
}, 1000 );
});
谢谢:)
记住孩子们,一定要把函数传递给setTimeout
和setInterval
!