title: Get Unique DOM elements in jQuery
body: <p>HTML:</p>
  
  <pre><code>&lt;span personname="Mr. Bean" class="person person-male"&gt;&lt;/span&gt;
  &lt;span personname="Neo" class="person person-male"&gt;&lt;/span&gt;
  &lt;span personname="Neo" class="person person-male"&gt;&lt;/span&gt;
  &lt;span personname="Trinity" class="person person-female"&gt;&lt;/span&gt;
  &lt;span personname="Trinity" class="person person-female"&gt;&lt;/span&gt;
  &lt;span personname="Neo" class="person person-male"&gt;&lt;/span&gt;
  &lt;span personname="Mr. Bean" class="person person-male"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>Array.prototype.unique =
      function () {
          var a = [];
          var l = this.length;
          for (var i = 0; i &lt; l; i++) {
              for (var j = i + 1; j &lt; l; j++) {
                  // If this[i] is found later in the array
                  if (this[i] === this[j])
                      j = ++i;
              }
              a.push(this[i]);
          }
          return a;
  };
  
  function unique(list) {
      var result = [];
      $.each(list, function (i, e) {
          if ($.inArray(e, result) == -1) result.push(e);
      });
      return result;
  }
  
  $.unique($('span.person').get()).length // ==&gt; 7
  $.unique($('span.person')).length       // ==&gt; 7
  
  $('span.person').get().unique().length  // ==&gt; 7
  
  unique($('span.person').get()).length   // ==&gt; 7
  unique($('span.person')).length         // ==&gt; 7
  </code></pre>
  
  <p>How do I get only the unique DOM elements?</p>
  
  <p>That is, <code>$('span.person).unique().length  // ==&gt; 3</code></p>
  
  <p>I am looking for an in-built function, if there is any.</p>