Quick question everyone. I know you can select multiple elements with jQuery and change CSS properties in one line of code, like this:
$("#custom-h1-id-6, #custom-h1-id-5, #custom-h1-id-4, #custom-h1-id-3, #custom-h1-id-2").css({ 'position' : 'absolute', 'opacity' : '0'});
But recently I was listening to the ShopTalk Podcast, during which they mentioned that it's a better idea to assign all of your DOM lookups to variables at the beginning of your Javascript file, and then use that variable throughout your file. This I did, and but when I got to the point where I needed to change the CSS of all those elements, I realized I couldn't think of another way to do so besides writing a single line for each element, like this:
n2.css({ 'position' : 'absolute', 'opacity' : '0'});
n3.css({ 'position' : 'absolute', 'opacity' : '0'});
n4.css({ 'position' : 'absolute', 'opacity' : '0'});
n5.css({ 'position' : 'absolute', 'opacity' : '0'});
n6.css({ 'position' : 'absolute', 'opacity' : '0'});
Is there a more concise way to change the css of all these variable equivalent to the one-line jQuery way? I could make an array and iterate through them I guess, but that almost defeats the performance point of not performing multiple DOM lookups on the same item...
I'm sure there's something simple I forgetting for this, thanks!