i cant seem to get this right and would like to know the exact syntax to use.
say i have two variables defined in jQuery
var cat = $('#cat');
var dog = $('#dog');
i want for example... hide both divs.
i know without the vars it would be $('#cat, #dog').hide();
no matter how i do it with the variables i cant get it to work.
(cat,dog).hide();
thanks!
cat.add(dog).hide()
You can use the add
method to add elements to an existing selector:
var dog = $('#dog'),
cat = $('#cat');
dog.add(cat).hide();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With