2013-04-16 65 views
0

對此並不陌生,試圖讓我的.js腳本在Coda2中工作。如果任何人有任何想法,爲什麼.js腳本文件沒有響應,這將是偉大的!.js腳本沒有響應

預先感謝您!

<!DOCTYPE html> 
<html> 
<head> 
    <title>Button Magic</title> 
    <link rel='stylesheet' type='text/css' href='stylesheet.css' /> 
    <script type= 'text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script> 
    <script type= 'text/javascript' src='script.js'></script> 
</head> 
<body> 
    <div><br/><strong>Click Me!</strong></div> 
</body> 

在腳本:

$(document).ready(function() { 
$('div').mouseenter(function() { 
    $('div').fadeTo('fast',1); 
}); 
$('div').mouseleave(function(){ 
    $('div').fadeTo('fast',0.5); 
}); 

});

在這裏我的代碼查找圖片:

http://postimg.org/image/qis0sitd1/

+2

請將此處的代碼粘貼爲文本。 – JJJ

+0

<!DOCTYPE HTML> \t \t \t 按鈕魔術 <鏈接相對= '樣式' 類型= '文本/ CSS' 的href = 'stylesheet.css中'/> <腳本類型=「文本/的JavaScript」 SRC = '的script.js'> \t \t


Click Me!
\t –

+0

要的問題,PLE酶。 – JJJ

回答

1

你必須包括jQuery庫。您可以使用Google CDN

<!DOCTYPE html> 
<html> 
    <head> 
     <title>Button Magic</title> 
     <link rel='stylesheet' type='text/css' href='stylesheet.css' /> 
     <script type= 'text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script> 
     <script type= 'text/javascript' src='script.js'></script> 
    </head> 
    <body> 
     <div><br/><strong>Click Me!</strong></div> 
    </body> 
</html> 
+0

我改變了頭,以符合你的建議。還有什麼我需要改變才能做出迴應?當我.mouseenter –

+0

仍然沒有功能在控制檯中是否有任何錯誤? – BenM

+0

http://postimg.org/image/8xdbtwbqd/ –

2

你還沒有添加腳本標記包括jQuery的。

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js' type='text/javascript'></script> 
+0

確實+是位於與html文件相同的目錄中的js文件? –

+0

我確實想知道,但從屏幕截圖看,好像是從看麪包屑。 – harriyott

+0

絕對在與html文件和css文件相同的目錄中。 –