title: Call show on array of jQuery objects
body: <p>I have a little problem concerning performance of <code>jQuery.show</code>.
  This problem occurs in IE8 (probably also versions below, but IE8 is of my interest).</p>
  
  <p>I have an array of jQuery objects, lets call it <code>elements</code>.
  I want to show them, so i did:</p>
  
  <pre><code>for (var i = elements.length - 1; i &gt;= 0; i--) {
      elements[i].show();
  }
  </code></pre>
  
  <p>The bottleneck seems to be the call to <code>show</code>. The array is already generated, so that takes no time. looping through an array should not be a problem either.</p>
  
  <p>I thought of reducing this to one call to <code>show</code> by creating a new jQuery element containing all my elements. but I was not sure how to do this. I tried by <code>jQuery.add</code>.</p>
  
  <pre><code>var $elements = elements[0];
  for (var i = elements.length - 1; i &gt;= 1; i--) {
       $elements = $elements.add(elements[i]);
  }
  $elements.show();
  </code></pre>
  
  <p>Now, this time it seems to be a problem with <code>jQuery.add</code>. Probably because it always creates a new object.</p>
  
  <p>So, I thought of three different approaches that could solve my problem. Maybe you can help me with one of them:</p>
  
  <ul>
  <li>Is there a jQuery method like <code>add</code> that does not return a new object, but instead adds it to the current jQuery element?</li>
  <li>Is there an easy and fast way to create a jQuery element by an array of jQuery elements?</li>
  <li>Is there a way to <code>show</code> all jQuery objects in an array in a faster way?</li>
  </ul>
  
  <p>Answering just one of the question would probably help me out here. My problem is, that jquery always expects an array of <code>DOM elements</code> and not an array of <code>jQuery elements</code> in its methods.</p>
  
  <p>Thanks a lot in advance!</p>
  
  <p>-- EDIT about the contents of <code>elements</code></p>
  
  <p>I have a jstree that dynamically creates nodes (that is, <code>li</code> elements). These elements have an attribute <code>data-id</code> to identify them.
  Now, I could always query for something like $('li[data-id=xxx]'), but this would be very slow. So instead, when <code>li</code> elements are created, i cache them into a dictionary like object (key is the data-id, value is the node). Out of this object, i generate my array <code>elements</code>. This happens very fast.
  The array can have a size of up to 4000 nodes. Every jQuery Element in the array only contains one DOM-Element (<code>li</code>).</p>