New to all of this and trying to get my .js script to work in Coda2. If anyone has any idea of why the .js script file is not responding, that would be great!

Thank you in advance!

<!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>

In the script:

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

});

Please find the image here of my code:

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

有帮助吗?

解决方案 2

You have to include the jQuery library. You can use the Google CDN for that:

<!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>

其他提示

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>

You haven't included the Jquery lib, please include one.

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top