jQuery 文本框自动完成未显示
jQuery textbox autocomplete not showing
我是 HTML 和 jQuery 的新手。最近,我正在尝试 jQuery 的自动完成功能,例如 here。除了 style.css 文件外,我使用了给定的源代码。到目前为止,
- 当我使用 Sublime Text 2 并在 Chrome 中预览时,没有显示自动完成功能。
- 当使用Whosebug提供的代码片段中的代码时,它工作正常。
怎么会?
谢谢。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</body>
</html>
您需要 运行 本地主机服务器上的文件。如果你只是打开 chrome 中的 html 文件,它将无法连接到外部 CSS 和 JS 文件,也不会执行其他 javascript在文件中。
我复制粘贴了您的代码并将其放在我的 Wamp 服务器上,它似乎对我来说工作正常。
1) 检查控制台是否有错误
2) 如果它抛出 jquery not found 错误更正路径
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
我是 HTML 和 jQuery 的新手。最近,我正在尝试 jQuery 的自动完成功能,例如 here。除了 style.css 文件外,我使用了给定的源代码。到目前为止,
- 当我使用 Sublime Text 2 并在 Chrome 中预览时,没有显示自动完成功能。
- 当使用Whosebug提供的代码片段中的代码时,它工作正常。
怎么会?
谢谢。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</body>
</html>
您需要 运行 本地主机服务器上的文件。如果你只是打开 chrome 中的 html 文件,它将无法连接到外部 CSS 和 JS 文件,也不会执行其他 javascript在文件中。
我复制粘贴了您的代码并将其放在我的 Wamp 服务器上,它似乎对我来说工作正常。
1) 检查控制台是否有错误
2) 如果它抛出 jquery not found 错误更正路径
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>