Javascript 未捕获的语法错误:意外的令牌非法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12680072/
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-23 11:00:25  来源:igfitidea点击:

Uncaught SyntaxError: Unexpected token ILLEGAL

javascripthtmlcsswordpresssyntax-error

提问by Nadim Dayoub

Possible Duplicate:
Unexpected token ILLEGAL in webkit

可能的重复:
webkit 中的意外令牌非法

I wrote a simple script for a hover over effect here http://jsfiddle.net/paDmg/368/for this site http://avuedesigns.com/new/- It works on jsfiddle, but I am getting

我在这里写了一个简单的脚本来实现悬停效果http://jsfiddle.net/paDmg/368/这个网站http://avuedesigns.com/new/- 它适用于 jsfiddle,但我得到

Uncaught SyntaxError: Unexpected token ILLEGAL

未捕获的语法错误:意外的令牌非法

in my JavaScript when I put it live. It's on line 29 it is telling me which is the closing marks });?

当我把它放在我的 JavaScript 中时。在第 29 行,它告诉我哪个是结束标记 });?

$('#hover-grid .indiv-cell').hover(function() {

//set variables to current cell attributes
var cellHeader = $(this).attr('data-hoverheader');
var cellText = $(this).attr('data-hovertext');
var replacementImg = $(this).find('a img').attr('data-replacementimg');
var oringinalImg = $(this).find('a img').attr('src');

//save original image to data variable
$(this).data('origImg', oringinalImg);

//add remove classes
$('#hover-grid .indiv-cell').removeClass('newClass');
$(this).addClass('newClass', 1000);
$(this).find('a img').hide().attr('src', replacementImg).fadeIn(300);
$('.master-cell h1').hide().text(cellHeader).fadeIn(300);
$('.master-cell p').hide().text(cellText).fadeIn(300);

//return false;
}, function() {
    $(this).find('a img').hide().attr('src', $(this).data('origImg')).fadeIn(10);
});?

回答by Juan Mendes

You probably have embedded illegal characters. Look in your JS with a hex editor and look for any characters that aren't visible ASCII characters. They may be getting stripped off by JSfiddle

您可能嵌入了非法字符。使用十六进制编辑器查看您的 JS 并查找任何不可见的 ASCII 字符。他们可能会被 JSfiddle 剥夺

See Chrome Uncaught Syntax Error: Unexpected Token ILLEGAL

请参阅Chrome 未捕获的语法错误:意外令牌非法