Unexpected end of input javascript
I have some JavaScript code that works in FireFox, but not in Chrome or IE. In Chrome JS console I get the following error: Msgstr “Uncaught SyntaxError: Unexpected end of input”. The JavaScript code I’m using: This indicates an error in the last line, which is }); Solution Add a second });. With the correct…
I have some JavaScript code that works in FireFox, but not in Chrome or IE.
In Chrome JS console I get the following error:
Msgstr “Uncaught SyntaxError: Unexpected end of input”.
The JavaScript code I’m using:
<script>
$(function() {
$("#mewlyDiagnosed").hover(function() {
$("#mewlyDiagnosed").animate({'height': '237px', 'top': "-75px"});
}, function() {
$("#mewlyDiagnosed").animate({'height': '162px', 'top': "0px"});
});
</script>
This indicates an error in the last line, which is });
Solution
Add a second });.
With the correct indentation, 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 external $(function() {.
The lesson is to always indent your code (and indent it correctly).