0

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/

3 Answers3

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>
harriyott
  • 10,505
  • 10
  • 64
  • 103
1

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

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

Eran
  • 387,369
  • 54
  • 702
  • 768
dreamweiver
  • 6,002
  • 2
  • 24
  • 39
1

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>
BenM
  • 52,573
  • 26
  • 113
  • 168
  • I changed the head to match what you advised. Is there anything else that I need to change to make it respond? Still no function when I .mouseenter – Timothy Kaye Apr 16 '13 at 09:39
  • Do you have this on a local server? Or are you running it using the `file:` protocol? – BenM Apr 16 '13 at 09:43
  • Its on my local computer. Do I have to put it up on the server to make it work? – Timothy Kaye Apr 16 '13 at 09:46
  • You do with that URL structure. For testing locally, append `http:` to the beginning of the Google link. I've updated the answer to make it clearer. – BenM Apr 16 '13 at 09:47
  • YOU are a LEGEND! Got it to work. I have been trying for hours. Thanks! – Timothy Kaye Apr 16 '13 at 09:52