2012-01-17 45 views
0

這是我的第一個jQuery腳本,它不會運行。你能告訴我什麼是錯的嗎?第一個jQuery腳本不會運行,出了什麼問題

在此先感謝。

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Furry Friends Campaign</title> 
     <link rel="stylesheet" type="text/css" href="styles/my_style.css"> 
    </head> 
    <body> 
     <div id = "clickMe">Show Me the Furry Friend of the Day</div> 
     <div id = "picframe"> 
      <img src="images/furry_friend.jpg"> 
     </div> 
      <script src = "scripts/jquery-1.6.2.min.js"></script> 
      <script> 
      $(document).ready(function(){ 
       $("#clickMe").click(function() { 
        $("img").fadeIn(1000); 
        $("#picframe").slideToggle("slow"); 
       }); 
      }); 
     </script> 
      </a> 
     </div> 
    </body> 
</html> 

我有我的jQuery的版本增加更新到1.7,並刪除周圍的賦值運算「=」多餘的空格:

我的問題仍然存在。樣式正在被應用,但是當我點擊腳本時沒有任何反應,也沒有出現「點擊」拇指圖標。

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Furry Friends Campaign</title> 
     <link rel="stylesheet" type="text/css" href="styles/my_style.css"> 
    </head> 
    <body> 
     <div id="clickMe">Show Me the Furry Friend of the Day</div> 
     <div id="picframe"> 
      <img src="images/furry_friend.jpg"> 
     </div> 
      <script src="scripts/jquery-1.7.min.js"></script> 
      <script> 
      $(document).ready(function(){ 
       $("#clickMe").click(function() { 
        $("img").fadeIn(1000); 
        $("#picframe").slideToggle("slow"); 
       }); 
      }); 
     </script> 
      </a> 
     </div> 
    </body> 
</html> 

這裏是CSS樣式表:

#clickMe { 
    background: #D8B36E; 
    padding: 20px; 
    text-align: center; 
    width: 205px; 
    display: block; 
    border: 2px solid #000 
    } 

#picframe { 
    background:#D8B36E; 
    padding: 20px; 
    width: 205px; 
    display: none; 
    border: 2px solid #000 
    } 
+1

這是什麼''在做您的標記?腳本究竟是如何運行*? – 2012-01-17 21:33:26

+0

你可以檢查你是否有jquery-1.6.2.min.js鏈接是否正確? – 2012-01-17 21:34:27

回答

3

確保scripts/jquery-1.6.2.min.js實際上是工作,而不是404使用firebug

但問題是有可能圍繞着空間的「=」,在腳本標記,它應該是這樣的:

<script src="scripts/jquery-1.6.2.min.js"></script> 
0

你躲在img第一?

我沒有看到你的CSS,所以我不能告訴。

但是,如果你不與img藏起,您將無法使用.fadeIn()

相關問題