【问题标题】:Uncaught SyntaxError: Unexpected token ILLEGAL? Looks Fine [duplicate]未捕获的语法错误:意外的令牌非法?看起来不错[重复]
【发布时间】:2012-08-24 13:33:42
【问题描述】:

可能重复:
Unexpected token ILLEGAL in webkit

我一直在看这个并且看不到问题,它在 jfiddle 中工作 - 只是不在网站上!

<script type="text/javascript">
var fixed = false;

$(document).scroll(function() {
    if( $(this).scrollTop() > 200 ) {
        if( !fixed ) {
            fixed = true;
            $('#menu-scroll').css({position:'fixed', display:'block'});
        }
    } else {
        if( fixed ) {
            fixed = false;
            $('#menu-scroll').css({display:'none'});
        }
    }
});​
</script>

该网站的链接是http://mtro.es/7

【问题讨论】:

  • 您的页面有几个 404 错误。使用开发控制台检查它。
  • 最后一个;后面确实有一个隐形字符。
  • 具体U+200B
  • 谢谢,没想到还有隐藏角色!

标签: javascript jquery css


【解决方案1】:

也许没有 id 为“menu-scroll”的 html 元素。你检查..

【讨论】:

  • 根据元素是否存在不会抛出语法错误;此外,如果元素不存在,jQuery 永远不会抛出错误。
猜你喜欢
  • 1970-01-01
  • 2018-02-12
  • 1970-01-01
  • 2015-09-07
  • 1970-01-01
  • 2013-02-20
  • 2012-10-18
  • 2014-02-09
  • 2011-04-07
相关资源
最近更新 更多