gpt4 book ai didi

javascript - 来自数组的 AutoSuggest

转载 作者:行者123 更新时间:2023-11-28 02:50:47 24 4
gpt4 key购买 nike

我有一个 php 脚本,可以生成这种形式的 JS 数组

new Array(

new Array("Maine", 1),

new Array("Maryland", 2),

new Array("Massachusetts", 3),

new Array("Michigan", 4),

new Array("Minnesota", 5),

new Array("Mississippi", 6),

new Array("Missouri", 7),

new Array("Montana", 8)

);

有人可以建议一下,如何为搜索表单实现自动建议吗?

谢谢

最佳答案

使用jQuery UI autocomplete :

Autocomplete can be customized to work with various data sources, by just specifying the source option. A data source can be:

  • an Array with local data
  • a String, specifying a URL
  • a Callback

The local data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.

关于javascript - 来自数组的 AutoSuggest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3800042/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com