JavaScript 错误(Uncaught SyntaxError: Unexpected end of input) [英] JavaScript error (Uncaught SyntaxError: Unexpected end of input)

查看:98
本文介绍了JavaScript 错误(Uncaught SyntaxError: Unexpected end of input)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 JavaScript 代码可以在 FireFox 中运行,但不能在 Chrome 或 IE 中运行.

I have some JavaScript code that works in FireFox but not in Chrome or IE.

在 Chrome JS 控制台中,我收到以下错误:

In the Chrome JS Console I get the follow error:

未捕获的语法错误:意外的输入结束".

"Uncaught SyntaxError: Unexpected end of input".

我使用的 JavaScript 代码是:

The JavaScript code I am using is:

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

它说错误在最后一行 });

推荐答案

添加第二个 });.

正确缩进时,您的代码会读取

When properly indented, your code reads

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

您从未关闭外部 $(function() {.

这篇关于JavaScript 错误(Uncaught SyntaxError: Unexpected end of input)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆