jQuery API | jQuery API 中英文对照版 - jQuery在线查询手册 |
$.grep(array, fn, inv) |
$.grep(array,fn,inv)
使用筛选函数,从一个数组中筛选项目。 其中筛选函数必须传递两个参数:数组中的当前项目和数组中项目的索引。如果要保持数组中的项目,这个函数必须返回true;如果返回false,就会删除项目。 返回值:Array 参数:
示例: $.grep( [0,1,2], function(i){ return i > 0; }); 结果: [1, 2] Filter items out of an array, by using a filter function. The specified function will be passed two arguments: The current array item and the index of the item in the array. The function must return 'true' to keep the item in the array, false to remove it. Return value: Array
Example: $.grep( [0,1,2], function(n,i){ return n > 0; });Result: [1, 2]
|