Search code examples
javascripthtmlcsscoda

.js script not responding


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/


Solution

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