我正在尝试为我的网站构建一个 jquery 插件,该插件使用自动完成来填写文本框。我试图将其称为:
$("#txtBox").suggest()
从我的 HTML 页面。这些是我的参考。
<!DOCTYPE html>
<html>
<head>
<title>Suggest</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script src="http://localhost:8080/Trial/test.js"></script>
<script type="text/javascript">
$(function () {
$("txtBox").suggest();
});
</script>
</head>
<body>
<p>Enter a Symbol:</p><br />
<input type = "text" id = "txtBox" />
</body>
</html>
这是我的插件 test.js:
(function ($) {
$.fn.suggest = function () {
//Autocomplete not found!
this.autocomplete ({
source: //Some source
},
minLength: 1
});
}(jQuery));
它说自动完成是未定义的。任何人都可以帮忙吗?