周期 2 未运行

Cycle2 not running

本文关键字:运行 周期      更新时间:2023-09-26

我需要使用 cycle2 为特定文件夹中的图像运行幻灯片。下面是我的标记和 php:

<div class="cycleShow">
    <?php
        $dir = 'img/';
        $files = scandir($dir);
        foreach($files as $file) {
            if($file !== '.' && $file !== '..'){
                $tag = '<img class="thumbNail" src="' . $dir . $file . '" />';
                echo $tag;
            }
        }
    ?>
</div>
<button onClick="slideshow();">Start</button>

和功能.....

    function slideshow() {
        $('.cycleShow').cycle();
    }

执行时,图像加载到div 中,但单击按钮时没有幻灯片。

您的div 类不正确,它应该是class='cycle-slideshow' .