I'd suggest giving the buttons specific Ids, and search by Id instead of class name. $("#favoritebtn") is faster than $(".faovittebtn")