YouTip LogoYouTip

Misc Uniquesort

# jQuery.uniqueSort() Method [![Image 3: jQuery Misc Methods](#)jQuery Misc Methods](#) ## Example Remove duplicate div elements from an array
There are 6 div blocks in the document
$(function(){// unique() must get a raw array var divs = $("div").get(); // Add 3 div block elements divs = divs.concat( $(".dup").get()); $("div:eq(1)").text("After reordering there are " + divs.length + " elements"); divs = jQuery.uniqueSort(divs);$.uniqueSort(document.getElementsByTagName("div")); $("div:eq(2)").text("After reordering there are " + divs.length + " elements") .css("color", "red"); }) [Try it Β»](#) * * * ## Definition and Usage The _$.uniqueSort()_ function sorts an array and removes any duplicate nodes by searching the array object. **Note:** Two different nodes with the same attributes are considered not duplicates. This function is mainly used internally by jQuery and only applies to arrays of plain JavaScript DOM elements. Before jQuery 3.0, this method was called jQuery.unique(). * * * ## Syntax _$.uniqueSort(array)_ | Parameter | Description | | :--- | :--- | | _array_ | Array type. The specified array of DOM elements. | * * jQuery Misc Methods](#)
← Misc PushstackProp Cssnumber β†’