下面是我的 json 输出:
{["0001000","0002000","0001200","00003000","990000","78888","89234","2345","2345"]}
如何使用上述 json 数组在文本框字段中实现自动建议?
下面是我的 json 输出:
{["0001000","0002000","0001200","00003000","990000","78888","89234","2345","2345"]}
如何使用上述 json 数组在文本框字段中实现自动建议?
恕我直言,您真的需要花一些时间来搜索和查看文档。
jQuery UI库已经提供了这个特性。
http://jqueryui.com/demos/autocomplete/
您需要在 HTML 页面中包含 2 个脚本
1) jQuery 库
2) jQuery UI 库
HTML
<input id="tags">
Javascript
$(function(){
var availableTags=["0001000","0002000","0001200","00003000","990000","78888","89234","2345","2345"];
$( "#tags" ).autocomplete({
source: availableTags
});
});
如果您使用的是 jQuery UI,关于自动完成的 jQuery 文档很简单。将您的阵列作为source:
,它应该会自动工作。
你应该去jQueryUI 自动完成
只需使用:
["0001000","0002000","0001200","00003000","990000","78888","89234","2345","2345"];
没有{}
像下面这样:
var json = ["0001000","0002000","0001200","00003000","990000","78888","89234","2345","2345"];
$('input:text').autocomplete(json, {
});
或者您可以自动设置来源
$(input:text).autocomplate({
souce: SOURCE_TO_YOUR_STORE
});