I have a button and it is generated dynamically. Initially it has the class "active" when u click on it class changes to "inactive". When u click again it should change to active.
So I have assigned click events using follwoing code.
$(".active").on("click",function(){
$(this).removeClass('active').addClass('inactive');
});
$(".inactive").on("click",function(){
$(this).removeClass('inactive').addClass('active');
});
Issue is every time first function get called. When I use live instead of on it works fine. How can i fix this.