I try to make custom links and then connect the AJAX to them. There is a standard script that works from the part, but if you click on link1 and back on All, then it will not work even though All no longer has a class active how can you solve this?

<li class=active><a href='#'>All</a> <li ><a href='#'>link1</a> <li ><a href='#'>link2</a> <li ><a href='#'>link3</a> jQuery('.tabs ul li[class="active"] a').on('click', function(event) { event.preventDefault(); }); jQuery('.tabs ul li[class!="active"] a').on('click', function(event) { event.preventDefault(); jQuery('.tabs ul li[class="active"]').removeClass( "active" ); jQuery(this).parent('li').addClass('active'); doajax(); }); 

    1 answer 1

    AJAX has nothing to do with it.

     jQuery('.tabs ul li a').on('click', function(event) { event.preventDefault(); if (!$(this).parent('li').hasClass('active')) { $(this).closest('.tabs').find('ul li.active').removeClass('active'); $(this).parent('li').addClass('active'); doajax(); } });