2014-04-15 24 views
0

我一直在努力,但用的fancybox沒有運氣圖像庫的fancybox不工作

在腦子裏,我的頁面鏈接到

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css"> 

這裏是我的鏈接cdnjs

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> 
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.6/jquery.mousewheel.min.js"></script> 
<script src="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script> 
<script src="js/main.js"></script> 

這裏有我的代碼在JS

$("a .fancybox").fancybox({ 
     openEffect : 'none', 
     closeEffect : 'none' 
    }); 

$("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.png'],a[href$='.gif']").attr('rel', 'gallery').fancybox(); 

這裏是我的html

<section class="col-1 first"> 
     <a class="fancybox" rel='gallery' href="images/my-office.jpg"><img src="images/my-office.jpg" /></a> 

     <h3>My office</h3> 
     <p>This is also called "The circle of neglect".</p> 
    </section> 

    <section class="col-1"> 
     <a class="fancybox" rel='gallery' href="images/my-cousin.jpg"><img src="images/my-cousin.jpg" alt="Eli Newton" title="Eli Newton" /></a> 
     <h3>My dear cousin</h3> 
     <p>My cousin is from Canada.</p> 
    </section> 
+0

通過「不幸」你的意思是它不會工作?你在瀏覽器的控制檯中是否有錯誤? –

回答

0

在代碼中,你需要刪除元素和類之間的空間,因爲他們都應該被引用同一個對象。換句話說,這

$("a .fancybox") 

應該

$("a.fancybox") 

乾杯!