In jQuery, we can add CSS classes to multiple elements, but with the element already cached in a variable, how can we perform the same operation?
Example:
// adicionar classe a ambos os elementos
$('#myEle, #anotherEle').addClass('johnDoe');
Cached elements:
var $ele1 = $('#myEle'),
$ele2 = $('#anotherEle');
// adicionar classe a ambos os elementos
$ele1.addClass('johnDoe');
$ele2.addClass('johnDoe');
How do I add a CSS class to $ele1
and $ele2
to one row?