$.grep()

$(function () {
var arr = [ 1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1 ];
$( "div" ).text( arr.join( ", " ) );
arr = jQuery.grep(arr, function( n, i ) {
return ( n !== 5 && i > 4 );
});
$( "p" ).text( arr.join( ", " ) );
arr = jQuery.grep(arr, function( a ) {
return a !== 9;
});
$( "span" ).text( arr.join( ", " ) );
})

 

1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1

1, 9, 4, 7, 3, 8, 6, 9, 1

1, 4, 7, 3, 8, 6, 1

posted @ 2017-08-16 14:35  老板、番茄炒蛋  阅读(214)  评论(0编辑  收藏  举报