利用JQuery find或inArray方法在数组中查找项目 [英] Leveraging JQuery find or inArray method to find an item in an array
本文介绍了利用JQuery find或inArray方法在数组中查找项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有人知道使用JQuery find方法或inArray方法在数组中查找项目的方法.我似乎在文档中找不到任何内容.
I was wondering if anyone knows of a way to use the JQuery find method or inArray method to find an item in an array. I can't seem to find anything in the docs.
例如:
var items = [{id:1, name:'bob'}, {id:2, name:'joe'}, {id:3, name:'ben'}];
var found = $(items).find("[name='ben']");
或
var items = [{id:1, name:'bob'}, {id:2, name:'joe'}, {id:3, name:'ben'}];
var found = $.inArray("[name='ben']", items);
推荐答案
我认为您正在寻找的是RichArray插件,更具体地说
I think what you are looking for is the RichArray plugin and more specifically
$.RichArray.filter()
您可以在 RichArray
这篇关于利用JQuery find或inArray方法在数组中查找项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文