I have a button with class try and when its clicked there is a function that is being called, now I want to create a button called start that will do the same, and I don't want to copy paste whole code in that button click handler, is there a way to say lets say if try or start do the following in jquery?
I assume that since you said a button called start that start is the id. That is why I am using a # instead of a . to reference it.
$('.try, #start').click(function(e){
YourFunction();
});
if start is the class, then use this. # indicates an id, while . indicates a class.
$('.try, .start').click(function(e){
YourFunction();
});
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