Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
554 views
in Technique[技术] by (71.8m points)

javascript - JavaScript错误(未捕获的SyntaxError:输入意外结束)(JavaScript error (Uncaught SyntaxError: Unexpected end of input))

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

(我有一些JavaScript代码可在FireFox中使用,但不能在Chrome或IE中使用。)

In the Chrome JS Console I get the follow error:

(在Chrome JS控制台中,出现以下错误:)

"Uncaught SyntaxError: Unexpected end of input".

(“未捕获的SyntaxError:输入意外结束”。)

The JavaScript code I am using is:

(我正在使用的JavaScript代码是:)

<script>
 $(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 });

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

  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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() { .

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...