I know "selectors" is the wrong term, but I can't remember it :P
I have this script:
$(function() {
//checkbox
$("#checkbox2, .akslabel").click(function(){
$("#scrollwrap").toggleClass('highlight');
});
});
Is it ok to stack up the selectors like that? Or should I re-write it for each one?
Thanks!
You can use as many selectors as you want combined with a , (the multiple selector) and bind the same anonymous function to them all, which is what your example does.
There's nothing wrong with this, it's cleaner/more concise code.
So can you "stack" selectors? Yes, think of them as waffles, very delicious waffles, with bacon.
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