【问题标题】:Error when using CDN for jQuery为 jQuery 使用 CDN 时出错
【发布时间】:2013-03-20 04:16:09
【问题描述】:

可能是显而易见的,但我对 jQuery 和 ajax 整体来说还是很陌生。环境 - ASP.NET

我是这样引用 jQuery 的:

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.1/jquery-ui.min.js" type="text/javascript"></script> 
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.1/themes/blitzer/jquery-ui.css" rel="stylesheet" type="text/css"/>

当我启动 web 项目时,我会弹出错误消息:

Unhandled exception at line 4, column 10920 in http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js

0x800a139e - JavaScript runtime error: Syntax error, unrecognized expression: img["data-over"]:eq(0)

我做错了什么?

【问题讨论】:

  • 您在 Visual Studio 中看到了,对吗?我会在对话框中输入continue,看看浏览器是否崩溃(F12 在 IE 中为您提供开发控制台)。 Visual Studio 捕获了许多浏览器忽略的 JS 异常。浏览器可能很好,而 VS 过于敏感。
  • 每个人都有自己喜欢的调试方法,但我几乎可以保证,如果你能熟练使用浏览器中的调试工具(IE 中的F12,Chrome 中的Ctrl+Shift+JFirebug Firefox 中的扩展)你会更喜欢 JS 开发

标签: jquery asp.net cdn


【解决方案1】:

data-over 是属性;它是值,如果你有的话,它会被放在引号中。

$('img[data-over]:eq(0)')

对比

$('img[data-over="somevalue"]:eq(0)')

请参阅this Fiddle 以获取演示。

【讨论】:

    猜你喜欢
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 2013-06-11
    • 1970-01-01
    • 2011-05-01
    • 1970-01-01
    相关资源
    最近更新 更多