Javascript 意外的输入结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26216939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 22:33:15  来源:igfitidea点击:

Unexpected end of input

javascriptjquerywordpress

提问by MariusNV

I have some issues with a JavaScript portion that I have added to my WordPress footer.php:

我添加到 WordPress footer.php 的 JavaScript 部分存在一些问题:

<script>
jQuery('.showPosts').on('click', function() {
    if (jQuery(this).hasClass('hidePosts')) {
        jQuery(this).children('div').hide();
        jQuery(this).removeClass('hidePosts');
        jQuery(this).children('.greekCross').html('&#10010;');
    } else {
        jQuery(this).children('div').show();
        jQuery(this).addClass('hidePosts');
        jQuery(this).children('.greekCross').html('&#160;&#10145;');
    }
});
jQuery('.search-field').attr('placeholder','TYPE IN SEARCH TAGS...');
jQuery('.videoText').remove();
jQuery('.ytVideoContainer').addClass('left');
jQuery('.catContainer').addClass('right');
jQuery('.catContainer').addClass('noMarginTop');
var mq = window.matchMedia('(min-width: 767px)');
if (mq.matches) {
    // window width is at least 767px
    jQuery('.relatedVideoThumb').show();
} else {
    jQuery('.postcontentTitle').insertBefore('.catContainer');
    jQuery('.postcontent').insertBefore('.catContainer');
    jQuery('.relatedVideoThumb').hide();
}
var winWidth  = 0;
jQuery(window).resize(function() {
    winWidth = jQuery(window).width();
    if (winWidth < 768) {
        jQuery('.postcontentTitle').insertBefore('.catContainer');
        jQuery('.postcontent').insertBefore('.catContainer');
        jQuery('.relatedVideoThumb').hide();
    } else {
    jQuery('.catContainer').insertBefore('.postcontent');
    jQuery('.catContainer').insertBefore('.postcontentTitle');
    jQuery('.relatedVideoThumb').show();
    }
});
jQuery('.site-header .home-link').css('border', '0');
</script>

Every time I reload the page I receive in the Google Chrome Console the following:

每次我重新加载页面时,我都会在 Google Chrome 控制台中收到以下信息:

Uncaught SyntaxError: Unexpected end of input

Uncaught SyntaxError: Unexpected end of input

Being minified for optimization purposes I had to look into Firefox Firebug extension to see where exactly is this unexpected end of input. I received the following:

为了优化目的而被缩小,我不得不查看 Firefox Firebug 扩展,看看这个意外的输入结束到底在哪里。我收到以下信息:

SyntaxError: missing } in compound statement
); }});jQuery('.site-header .home-link').css('border', '0');
------------------------------------------------------------

I don't see where I could had done something wrong, I've more than double check it but I am unable to find the mistake so any guidance or solution is more than welcomed.

我不知道我哪里做错了,我已经仔细检查过,但我找不到错误,所以任何指导或解决方案都非常受欢迎。

采纳答案by Asenar

SyntaxError: missing } in compound statement

SyntaxError: missing } in compound statement

This error message tells you to add a }is missing at this point.

此错误消息告诉您此时添加}缺失。

Try to add it.

尝试添加它。

I suppose you will also have to add )to complete your javascript code.

我想您还必须添加)以完成您的 javascript 代码。