0

所有这一切都是新手,并试图让我的 .js 脚本在 Coda2 中工作。如果有人知道为什么 .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/

4

3 回答 3

2

You haven't added a script tag to include jQuery.

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js' type='text/javascript'></script>
于 2013-04-16T09:07:01.910 回答
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>
于 2013-04-16T09:12:37.183 回答
1

您还没有包含 Jquery 库,请包含一个。

例如:http ://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

于 2013-04-16T09:10:45.557 回答