javascript jQuery-UI:未捕获的语法错误:意外的令牌
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15453393/
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
jQuery-UI: Uncaught SyntaxError: Unexpected token
提问by Gill Bates
Here is what I have in HTML:
这是我在 HTML 中的内容:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/static/jslibs/jquery-ui-1.10.2.custom/css/ui-lightness/jquery-ui-1.10.2.custom.css"></script>
<title>test</title>
</head>
<body>
</body>
</html>
And here is what I got with it:
这是我得到的:
Uncaught SyntaxError: Unexpected token .
...Here code caused exception...
.ui-helper-hidden {
display: none;
}
Does anybody familiar with it?
有人熟悉吗?
回答by Denys Séguret
You're confusing js files and css files.
你混淆了 js 文件和 css 文件。
You're using a script element to import a css file, hence the error. JQuery UI needs both a CSS file and a JS file, and they must be imported in separate elements. It should look like this :
您正在使用脚本元素导入 css 文件,因此出现错误。JQuery UI 需要一个 CSS 文件和一个 JS 文件,它们必须在单独的元素中导入。它应该是这样的:
<link type="text/css" href="lib/jquery/ui-darkness/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
<script charset="UTF8" src="jquery.min.js"></script>
<script charset="UTF8" src="lib/jquery/jquery-ui-1.9.0.custom.min.js"></script>