$('.push').each(function(){
if($(':first-child',this).hasClass( "activex" )){
$(this).off().off('click').on('click',function(){
var a = $(this).attr('id');
$.ajax({
type: "POST",
url: "includes/rcart.php",
data:{'pid': a},
success: function(data){
var a= parseInt($('.cart').text());
if((data.indexOf("2")) >= 0){
console.log(data);
console.log('not removed');
}else{
a--;
console.log('removed');
$(this).children().removeClass('activex');
$('.cart').text(a);
}
}
});
console.log(a);
});
}else{
$(this).on('click',function(){
var a = $(this).attr('id');
$.ajax({
type: "POST",
url: "includes/cart.php",
data:{'pid': a},
success: function(data){
console.log(data);
var a= parseInt($('.cart').text());
if((data.indexOf("2")) >= 0){
console.log('done');
}else{
a++;
$('.cart').text(a);
$(this).children().addClass('activex');
}
}
});
console.log(a);
});
}
});
I am facing an issue where the code is unable to remove the class activex when a button with the push class is clicked. Strangely, there are no errors in the code and despite removing the class manually in the Chrome Developer Console, the class does not get removed.