JQuery UI Autocomplete使用ID(值)而不是Label设置默认值VALUE [英] JQuery UI Autocomplete set default VALUE using ID (value) instead of Label

查看:270
本文介绍了JQuery UI Autocomplete使用ID(值)而不是Label设置默认值VALUE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我创建了一个JQuery UI Autocomplete,其中source是一个标签 - 值对数组。

i需要设置默认的选定项目。我找到了一种方法,使用所需的标签,

但如果我有 VALUE 而不是 LABEL ,我怎么能这样做?



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



dear all,
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有价值,而不是标签。如何根据值设置所选项?

提前感谢



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

推荐答案

myAutoCom)。autocomplete( search someLabel);
var menu =
("myAutoCom").autocomplete("search", "someLabel"); var menu =


myAutoCom)。autocomplete( widget) ;
("myAutoCom").autocomplete("widget");


(菜单[ 0 ]。children [ 0 ] ).click();
(menu[0].children[0]).click();





i有值,而不是标签。如何根据价值设置所选项目?

提前感谢



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


这篇关于JQuery UI Autocomplete使用ID(值)而不是Label设置默认值VALUE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆