I have this code:
$("#leftbutton").click(function(e){
/// do xyz
});
$("#rightbutton").click(function(e){
/// do xyz (same thing)
});
How do I combine them so that if you click #leftbutton or #rightbutton it does xyz?
Something like this:
$("#leftbutton OR #rightbutton").click(function(e){
/// do xyz
});
Use the comma, also known in the jQuery docs as the multiple selector:
$("#leftbutton, #rightbutton").click(function(e){
/// do xyz
});
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