简体   繁体   English

如何合并这两个JQuery语句?

[英]How Do I Combine These Two JQuery Statements?

How do I combine these two JQuery statements? 如何结合这两个JQuery语句? This is for a bootstrap carousel manipulated with JQuery. 这是用于通过JQuery操作的引导轮播。

$('.carousel').carousel(randomNumber);

and

$('.carousel').carousel({ interval: 6500 })

The first statement sets a random slide, and the second sets the interval. 第一个语句设置随机幻灯片,第二个语句设置间隔。 I know this should be relatively easy but I've had some trouble figuring it out and I can't find any other examples. 我知道这应该相对容易一些,但是我在解决它时遇到了一些麻烦,而且找不到其他示例。

The two methods are totally different. 两种方法完全不同。

This method is to set options for a carousel which can contain interval, pause, and wrap. 此方法用于设置轮播的选项,其中可以包含间隔,暂停和换行。

$('.carousel').carousel({ interval: 6500, pause: "hover", wrap: true });

However, this method is to set a current slide. 但是,此方法是设置当前幻灯片。

$('.carousel').carousel(number);

It's impossible to call the methods at the same time, but you can use chaining like below: 不可能同时调用方法,但是可以使用如下所示的链接:

$('.carousel').carousel({ interval: 6500}).carousel(randomNumber);

Check here 在这里检查

You will see the carousel moving to the 3rd slide as soon as it loads. 加载后,您会看到轮播会移动到第三张幻灯片。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM