2014-12-06 59 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