var Tabs = { create : function() { // We search all the div with "tab" class var tabs = document.querySelectorAll('.tabelem'); var current = null; // We create the list var html = ''; for (var i=0; i'; html += ' ' + tabs[i].title + ''; html += ''; } // We show the first tab tabs[0].style.display = "inline-block"; // We insert the list document.querySelector('#navtabs').innerHTML = html; if(current != null){ tab = current; menuTab = document.querySelector('li.'+current); } //if no tab is active, activate the first one else { tab = document.querySelector('.tabelem').id; menuTab = document.querySelector('li.'+tab); } Tabs.change(menuTab, tab); }, change : function(current, n){ // We grab the tabs list var navtabs = document.querySelectorAll('#navtabs li'); // We clean the class of the li for (var j=0; j