2014-12-06 61 views
0

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

<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中。但没有点击按钮幻灯片。

+1

你是否检查过开发者工具中的任何js erros? – 2014-12-06 10:48:04

+2

不应该是'onclick =“...”'? – lexith 2014-12-06 10:49:53

+0

没有js错误,什么都没有。 – Tom 2014-12-06 11:09:37

回答

0

你的班级为格是不正确的应该是class='cycle-slideshow'

+0

请在解决问题的原因和方式上添加一些关于解决方案的意见 – 2015-12-03 16:56:24