jQuery.unique on an array of strings

后端 未结 8 579
野趣味
野趣味 2020-11-29 05:16

The description of jQuery.unique() states:

Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays

8条回答
  •  星月不相逢
    2020-11-29 05:38

    $.unique will only remove duplicate DOM element, if you need it for array :

    var result=[] ;
    $.each([12,1,2,4,3,1,4,3,3,2,111], 
            function(i,e){ if($.inArray(e,result)===-1) result.push(e) ;});
    result;
    

提交回复
热议问题