jQuery call same function when two different buttons are clicked

function, jquery

Solution

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();
});

Problem

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?

Original source