Home » Javascript » call single function for multiple classes

call single function for multiple classes

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have two button. One with class btn-star and other with btn-current. I am calling an independent function on each of their clicks. But now, I want to call only one function when they are called?

My code is similar to this:

$('document').ready(() => {
 $(document).on('click', '.btn-star', function () {
    // Do stuff
 }
 $(document).on('click', '.btn-current', function () {
    // Do stuff
 }
}
Answers: