Issue on Skip Adding Class to an Element Which Has a Specific Class

Issue on Skip Adding Class to an Element Which Has a Specific Class

Can you please take a look at This Demo   and let me know how I can prevent adding  active  class to the divs that have  d-none  class already? as you can see from my code I am adding the  active  class by index to all  .tab-pane  divs but I want to skip adding the active to the div with  d-none  class and add it to next available element



$("button").on("click", function(){ var index = $("#content-tabs .tab-pane.active").index(); index = index+1; $(".tab-pane").removeClass('active'); $(".tab-pane").eq(index).addClass('active'); });

I also tried this, but it is not working!

$("button").on("click", function(){ var index = $("#content-tabs .tab-pane.active").index(); index = index+1; $(".tab-pane").removeClass('active'); var elem = $(".tab-pane"); if (!elem.hasClass("d-none")) { elem.eq(index).addClass('active'); } });