Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery selector, chaining
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/1881716/merging-jquery-objects">Merging jQuery objects</a> </p> </blockquote> <p> <br /> ** The goal is performance. The duplicate question addresses the function, but I don't believe adds performance value and doesn't address that aspect. ** <br /><br /> I want to chain several jQuery elements, for the sake of performance, but for optimization sake they're already cached in variables. </p> <p>so if I have</p> <pre><code>$elem1 = $('div#elem1'); $elem2 = $('div#elem2'); $elem3 = $('div#elem3'); </code></pre> <p>This doesn't work so well:</p> <pre><code>$elem1,$elem2,$elem3.hide(); </code></pre> <p>Is there any way to do that, chaining with already cached elements? </p> <p>Thanks!</p> <p>[Edits]<br /> Ok, I really need to clarify. My goal for chaining is performance, with the bonus of concise yet clear code.<br> $('div#elem1, div#elem2, div#elem3').hide(); <br /> defeats the point as it's no longer using the cached vars, but accessing the dom again. Accessing the dom is expensive, so i'm pretty sure it's slower than the 3 lines. <br /> .add() and .merge(), I'm assuming are more expensive than seperating the operation on three lines. For performance sake, until I have time to jPerf, I'll assume 3 different lines rather than extra operations has the best performance.<br> <br /><br /> Thanks for the collaboration, brainstorming, and thoughts, I do appreciate it. I wasn't aware of the possibilities and wouldn't have known what to test on jPerf otherwise. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload