views:

33

answers:

2

I have some JavaScript code that works in FireFox but not in Chrome or IE. In the Chrome JS Console I get the follow error: "Uncaught SyntaxError: Unexpected end of input".

The JavaScript code I am using is (updated code) Sorry miss typed. I get the error with this code:

<script>
//<![CDATA[
$(function() {
    $("#mewlyDiagnosed").hover(function() {
        $("#mewlyDiagnosed").animate({'height': '237px', 'top': "-75px"});
    }, function() {
        $("#mewlyDiagnosed").animate({'height': '162px', 'top': "0px"});
    });
});​
//]]> 
</script>

It says the error is on the last line which is });

Any ideas why I would be getting this?

Thanks!

+2  A: 

Add a second });.

When properly indented, your code reads

$(function() {
    $("#mewlyDiagnosed").hover(function() {
        $("#mewlyDiagnosed").animate({'height': '237px', 'top': "-75px"});
    }, function() {
        $("#mewlyDiagnosed").animate({'height': '162px', 'top': "0px"});
    });
MISSING!

You never closed the outer $(function() {.

SLaks
The lesson is, **always indent your code** (and indent it correctly).
SLaks
+1  A: 

formatting your code a bit, you have only closed the inner hover function. You have not closed the outer parts, marked below....

$(// missing closing)
 function() { // missing closing }
     $("#mewlyDiagnosed").hover(
        function() {
            $("#mewlyDiagnosed").animate({'height': '237px', 'top': "-75px"});
        }, 
        function() {
            $("#mewlyDiagnosed").animate({'height': '162px', 'top': "0px"});
        });
hvgotcodes