3

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>
4
  • How do you know the problem is there to begin with? Commented Dec 30, 2012 at 14:07
  • Because it shows on line 21 of my site, which is </script> Commented Dec 30, 2012 at 14:09
  • 1
    Please paste all the relevant source Commented Dec 30, 2012 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. Commented Dec 30, 2012 at 14:12

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

jsbeautifier.org fixed it all =] Thank you.

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.