4
In jQuery, we can add CSS classes to multiple elements, but with the element already cached in a variable, as we can 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 to add a CSS class to a line $ele1
and $ele2
?
good, did not know this class to work more than one element at a time...
– LeandroLuk
@Leandroluk, Yes, I discovered the same when I asked the question/answer :)
– Zuul