i am trying to use a simple method to invoke two functions based on the class name selector. it's a toggling function. so function A toggles the class name so that the class name matches the selector used for function B and vice a versa. The problem is even after the element class has been changed jquery seems to be firing the function for the old class.
example.
$(".unfav").bind('click', function (e) {
$(this).toggleClass('unfav fav');
});
$(".fav").bind('click', function (e) {
$(this).toggleClass('fav unfav');
});
if .fav
was rendered originally and was triggered the consecutive clicks to the same element executes the .fav
selector and not the .unfav
selector. i tried using .on
and doesn't seems to help.
How do it force jQuery to unbind the original trigger when class is changed?