简体   繁体   中英

Combine two line of codes in one function with JavaScript

I'm using Cycle slideshow and setTimeout() to give it seconds of delay

I want to to combine these two line of codes below to execute them simultaneously. But, I don't know how to accomplish this in JavaScript.

$('#slideshow').cycle('resume');
$('#slideshow').cycle({
                        sync:  false,
                        speed: 300,
                     })

I want to put them in one line like this:

$('#slideshow').cycle(??????///here is your help////??????");

If I don't do this, the slide show, again, starts from the initial point and I don't want it.

How may I solve this?

尝试这个:

$('#slideshow').cycle('resume').cycle({sync:  false,speed:300,});

Without looking in detail at the plugin's source code, I think from your description, that the plugin automatically starts from beginning whenever you set its options. That seems reasonable, as the plugin likely has to recalculate things from scratch whenever its options are changed.

Can you set the options once, eg during initialization, halting it then if necessary:

$('#slideshow').cycle({sync:false, speed:300}).cycle('pause');

Later, when you want to start the show, just resume it

$('#slideshow').cycle('resume');

Alternatively, you could look into setting the global options before initializing the slideshows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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