I have an issue with linking to specific tabs in Visual Composer. I have added this script to change the content to the desired tab:
jQuery(window).load(function() {
if(location.hash) {
var panelRef = (window.location.hash.substring(1));
jQuery(".tab-content").each(function(index) {
if(jQuery(this).attr("id") == panelRef) {
jQuery("#tab-1441522486246-5-7").css("display","block");
jQuery("#tab-1441518864-1-47").css("display","none");
}
});
}
});
The content shows up correctly but the active tab still reverts to the first one. Is there a way where I can change it using script instead?
Here's a rough idea of what I'm trying to achieve, which I'm sure is incorrect:
jQuery(window).load(function() {
if(location.hash) {
var panelRef = (window.location.hash.substring(1));
jQuery(".tab-content").each(function(index) {
if(jQuery(this).attr("id") == panelRef) {
jQuery("#tab-1441522486246-5-7").css("display","block");
jQuery("#tab-1441518864-1-47").css("display","none");
}
var alink = document.getElementsByTagName('li').getElementsByTagName('a').attr("href");
var blink = document.getElementsByTagName('li').getElementsByTagName('a').attr("href");
var first = "#tab-1441518864-1-47";
var last = "#tab-1441522486246-5-7";
if(alink.attr("href") == first) {
alink.toggleClass("selected");
}
if(alink.attr("href") == last) {
blink.toggleClass("selected");
}
});
}
});
Any ideas?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire