zipjo
Forum Replies Created
Viewing 1 replies (of 1 total)
-
I fixed the code, if anyone still needs it. Thanks a lot OP!
(only works onload for now. You’d have to use onhashchange and maybe wrap it in a function for in-site use…)
jQuery(document).ready( function( $ ) { //check if there are any eael advanced tabs and if there's a hash. if($('.eael-advance-tabs').length && "" != window.location.hash){ let tabTitle = new Array(); let i =-1; let hashUrl = window.location.hash; let hashUrlStrip = hashUrl.replace('#',''); //set class from innerText of .eael-tab-title and push to array $('.eael-tabs-nav .eael-tab-title').each(function(){ let titleName = this.innerText.replace(/[\s??ü?]+/g, '-').toLowerCase(); $(this).parent().addClass(titleName); tabTitle.push(titleName); //check against link and activate correct tab if($(this).parent().hasClass(hashUrlStrip)){ $(this).parent().addClass('active').removeClass('inactive').removeClass('active-default'); } else{ $(this).parent().addClass('inactive').removeClass('active').removeClass('active-default'); } }); //do the same thing with the content $('.eael-tabs-content > div').each(function(){ //since the content is in the same order as the title, just compare the array-position (you could solve this with one more int as well...) if(tabTitle[++i] == hashUrlStrip){ $(this).addClass('active').removeClass('inactive').removeClass('active-default'); } else{ $(this).addClass('inactive').removeClass('active').removeClass('active-default'); } }); } });
Viewing 1 replies (of 1 total)