1

In the head of my document, I have two script references:

This is my html code

  <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
  <script src='Newproject\Success.js'></script>

In my Success.js file, I have the following jQuery code:

$(document).ready(function(){
    $('div').hover(function(){
        $(this).addClass('hover')
    },
    function(){
        $(this).removeClass('hover')
    )};
)};

Despite that I have referenced Success.js in my HTML file, the code does not execute.

4
  • Did you import the jquery library? Commented Nov 11, 2016 at 15:22
  • Well she did, as you can see from the first link. Commented Nov 11, 2016 at 15:28
  • shouldn't it be src='Newproject/Success.js'>? Commented Nov 11, 2016 at 15:28
  • btw: when referencing files on the server(and urls in general) you never use backslashes, just the good old /. Commented Nov 11, 2016 at 15:30

2 Answers 2

2

Change )} to }):

$(document).ready(function(){
    $('div').hover(
        function(){
            $(this).addClass('hover')
        },
        function(){
            $(this).removeClass('hover')
        }
    ) // it is }) indeed
});
Sign up to request clarification or add additional context in comments.

2 Comments

He's passing two functions into the .hover jQuery method but ends the parentheses before the end of his second parameter. Right.
@Crowes Can you use your eyes to watch carefully?
0

if they are in the same folder then your script src path should just be Success.js

<script src='Success.js'></script>

1 Comment

Yeah, this or src="/Success.js". Your document is looking for the folder Newproject with a .js file in it, whereas the .js file is at root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.