I have two variables defined like this:
var $a = $('#a'),
$b = $('#b');
How can I rewrite the following line using $a and $b?
$('#a, #b').click(function(e){...});
$([$a.get(0), $b.get(0)]).click(function(e) { ... });
$a.add($b).click(function(e){...});
add
returns a new node set holding the union. $b can be "pretty much anything that $() accepts."
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