Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

jQuery noob checking in here. What is wrong with my syntax? I get Unexpected End of Input in Chrome console.

 <script>
$('a[href*=#]:not([href=#])').click(function() {
  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
     || location.hostname == this.hostname) {

     var target = $(this.hash);
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
          $('html,body').animate({
              scrollTop: target.offset().top
         }, 1000);
         return false;
        }
     }
 });
</script>
share|improve this question
    
How do you know the problem is there to begin with? – Alexander Dec 30 '12 at 14:07
    
Because it shows on line 21 of my site, which is </script> – Necro. Dec 30 '12 at 14:09
1  
Please paste all the relevant source – Alexander Dec 30 '12 at 14:10
    
@Alexander, That's all the relevant source there is. Line 21 is </script> above it is a <title> and two tags specifying the html and head tag. – Necro. Dec 30 '12 at 14:12

2 Answers 2

up vote 6 down vote accepted

It means you've forgotten a closing }, ), >, or whatever is used in its syntax. Check all of your blocks and statements to see if you've left out any closing mark.

if you copy your code into jsbeautifier.org, click on "Beautify" and see if all of the indentations are correct.

share|improve this answer
    
jsbeautifier.org fixed it all =] Thank you. – Necro. Dec 30 '12 at 14:15

You should paste this code into your html page or remove the <script> tags if you are in a pure js file

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.