Why addclass not working?

jQuery('.product-tabs .tab_osnovnoe').on('click', function() {
 jQuery("#pa_vkladki option[value='osnovnye-foto']").prop("selected", true).trigger('change');
 jQuery('.product-tabs .tab_osnovnoe').addClass('active');
 jQuery('.product-tabs li').removeClass('active');

trigger('change') works, adding and removing a class does not work, tried this also not working. All of this wrapped in jQuery( document ).ready(function() , tried without. It is not clear, in the console there are no errors, but if in console write
jQuery('.product-tabs .tab_osnovnoe').addClass('active');
then everything works.
March 23rd 20 at 19:19
2 answers
March 23rd 20 at 19:21
What you have going on there, that only you know.
But I think you have."tab_osnovnoe" this element "li" and it works like this:
jQuery('.product-tabs .tab_osnovnoe').addClass('active'); // <- here you add a class
jQuery('.product-tabs li').removeClass('active'); // <- then immediately deleted the class
Yes, it's funny =) - Eulalia_Breitenberg commented on March 23rd 20 at 19:24
March 23rd 20 at 19:23
remove the class from the next elements before and look for selectors with this class active
when hanging class on clicked element, refer to this

jQuery('.product-tabs li.active').removeClass('active'); 

Find more questions by tags JavaScript