【问题标题】:Uncaught SyntaxError: Unexpected token ILLEGAL [duplicate]Uncaught SyntaxError: Unexpected token ILLEGAL [重复]
【发布时间】:2012-09-22 16:52:55
【问题描述】:

可能重复:
Unexpected token ILLEGAL in webkit

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

Uncaught SyntaxError: Unexpected token ILLEGAL

当我把它放在我的 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);
});​

【问题讨论】:

  • 检查您的 JS 中是否存在无效的嵌入字符,例如空值,这些字符可能会被 JSfiddle 删除。
  • 你的代码只有 25 行...
  • @Nadim Dayoub:仅供参考bugs.jquery.com/ticket/11731
  • 如果您在 google 上搜索“意外令牌非法”,前 10 名的点击都可以解决您的问题。

标签: javascript html css wordpress syntax-error


【解决方案1】:

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

Chrome Uncaught Syntax Error: Unexpected Token ILLEGAL

【讨论】:

  • 谢谢,删除最后一行并重新输入,没有更多错误。现在我要弄清楚为什么它现在不起作用了......
猜你喜欢
  • 2012-11-20
  • 2012-01-30
  • 2011-12-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-12
  • 1970-01-01
  • 2013-06-19
相关资源
最近更新 更多