自动完成jQuery插件:选择数组索引中的价值 [英] Autocomplete jQuery Plugin : Value of selected array index
本文介绍了自动完成jQuery插件:选择数组索引中的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在数组中的索引位置,其元素的用户使用了自动完成所选择的价值?
How do I get the value of the index position in the array, whose element the user had chosen using the autocomplete?
有关如如果我进入有两个元素作为自动完成插件的输入数组:
For e.g. if I enter the array having two elements as the input for the autocomplete plugin:
var arr = [];
arr[0] = "John";
arr[1] = "Paul";
然后,说用户选择保罗,我如何才能选择指数的值为1?
Then, say user selects "Paul", how do I get the value of the selected index "1"?
推荐答案
据我了解你的问题,你可能只是做类似
As I understand your question, you could just do something like
function FindIndex( arr, searchValue ){
for( var i = 0; i < arr.length; ++i ){
if( arr[i] === searchValue ){
return i;
}
}
}
这篇关于自动完成jQuery插件:选择数组索引中的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文