Javascript 循环2未运行
我需要使用cycle2为特定文件夹中的图像运行幻灯片放映。下面是我的标记和php:Javascript 循环2未运行,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我需要使用cycle2为特定文件夹中的图像运行幻灯片放映。下面是我的标记和php: <div class="cycleShow"> <?php $dir = 'img/'; $files = scandir($dir); foreach($files as $file) { if($file !== '.' && $file !== '..'){ $t
<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>
执行时,图像加载到div中。但单击按钮时没有幻灯片显示。您的div类不正确,应该是
class='cycle-slideshow'
您是否检查过开发工具中的任何js错误?不应该是onclick=“…”
?没有js错误,没有。请添加一些关于您的解决方案的评论,说明为什么以及如何解决问题
function slideshow() {
$('.cycleShow').cycle();
}