jQuery click event but with multiple targets

Is their a way in jQuery to say if i click button1 or button2 run this code?

Currently you do this for button clicks with jQurey:

$("#button1").click(function() {

}

But can i also add #button2 in their?

Sure, just add the other selector separated by a comma like:

$("#button1, #button2").click(function() {
  
})
2 Likes