JQuery UI Autocomplete使用ID(值)而不是Label设置默认值VALUE(JQuery UI Autocomplete set default VALUE using ID (v

编程入门 行业动态 更新时间:2024-10-27 00:29:03
JQuery UI Autocomplete使用ID(值)而不是Label设置默认值VALUE(JQuery UI Autocomplete set default VALUE using ID (value) instead of Label)

我创建了一个JQuery UI Autocomplete,其中source是一个标签值对的数组。 我需要设置默认选中的项目。 我找到了一种方法,使用所需的标签,但如果我有VALUE而不是LABEL ,我怎么能这样做?

使用标签字符串设置默认值的代码:

$("myAutoCom").autocomplete("search", "someLabel"); var menu = $("myAutoCom").autocomplete("widget"); $(menu[0].children[0]).click();

我有价值,而不是标签。 如何根据值设置所选项目? 提前致谢

i've created a JQuery UI Autocomplete in which the source is an array of label-value pairs. i need to set the default selected item. i found a way to do that using the desired label, but how can i do that if i have the VALUE instead of the LABEL?

code for setting default value using label string :

$("myAutoCom").autocomplete("search", "someLabel"); var menu = $("myAutoCom").autocomplete("widget"); $(menu[0].children[0]).click();

i have the value,not the label. how can i set selected item depending on value? thanks in advance

最满意答案

因为我的自动完成源是一个包含所有标签值对的数组,并且因为我将该数组保存在全局变量中,所以我只是执行了以下操作:

在THAT数组中搜索给定值并返回相应的标签,然后使用该标签使用问题中提到的代码初始化自动完成。

感谢@ sepikas-antanas

since the source of my autocomplete is an array that contains all label-value pairs, and since i keep that array in a global variable, i just did the following:

searched THAT array for the given value and returned the corresponding label, then used that label to initialize the autocomplete using the code mentioned in the question.

thanks to @sepikas-antanas

更多推荐

标签,label,设置,电脑培训,计算机培训,IT培训"/> <meta name="description"

本文发布于:2023-07-04 06:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1019748.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:默认值   而不是   Autocomplete   UI   JQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!