Invoking a method on multiple cached DOM elements

Viewed 65

I always trying to cache DOM selection when using jQuery to manipulate DOM. And I always thought if is it possible to shorthand such method calling:

var $cached_1 = $('#elem1'),
    $cached_2 = $('#elem2');

//For example i need toggle both I write like : 
$cached_1.toggle();
$cached_2.toggle();

Without the cache it is easy:

$('#elem1, #elem2').toggle();

But what about cached selections? Is there a similar way to call a method for few separate selections stored in variables?

2 Answers
Related