js filter用法

1、filter 充当过滤器的作用,以下例子是在input[class=category]中过滤出’value=type ‘的input 

var stone = $('input[class=category]').filter('[value='+type+']');
2、复杂点的例子,
function whatDoesItDo(arr){
 return arr.filter(function(elem, pos) {
return arr.indexOf(elem) == pos;
});
};

 

posted @ 2017-03-06 13:40  h88829  阅读(210)  评论(0编辑  收藏  举报