Thanks to the several answers found at Stack Overflow I have made the following construction that works as it should with no problem: https://jsfiddle.net/cL1xw2y5/
The real problem is that when the page loads it is only top level navigation menu visible with no items selected. Also when any top level button opens associated side menu there is no item in side menu selected also. And therefore no content is displayed.
As I'm a total noob in any kind of programming I'm courteously asking for your kind help with the following matters:
- I need any one of the top menu items preselected with appropriated side menu opened when the page loads.
- I also need any one of the side menu items preselected with appropriated content displayed when the page loads or top level menu item activated/preactivated.
May be even in random order, say, randomly activated top level menu item shows its side menu with randomly activated side menu item showing its content.
Any kind of help would be geatly appreciated. Thanks in advance.
Hope I'm not asking too much. :)
Here is the JS for jQuery used for showing/hiding elements that needs to be updated:
$(function() {
$('#sub_1_1 li').click(function() {
$('#sub_1_1 li').removeClass('sub_1_sub_active');
$('#sub_1_2 li').removeClass('sub_1_sub_active');
$(this).addClass("sub_1_sub_active");
});
});
$(function() {
$('#sub_1_2 li').click(function() {
$('#sub_1_1 li').removeClass('sub_1_sub_active');
$('#sub_1_2 li').removeClass('sub_1_sub_active');
$(this).addClass("sub_1_sub_active");
});
});
$(function(){
$('#top a').click(function(e){
hideContentDivs();
var tmp_div = $(this).parent().index();
$('.top div').eq(tmp_div).show();
});
function hideContentDivs(){
$('.top div').each(function(){
$(this).hide();});
}
hideContentDivs();
});
$(function(){
$('#sub_1_1 a').click(function(e){
hideContentDivs();
var tmp_div = $(this).parent().index();
$('.sub_1_1 div').eq(tmp_div).show();
});
function hideContentDivs(){
$('.sub_1_1 div').each(function(){
$(this).hide();});
$('.sub_1_2 div').each(function(){
$(this).hide();});
}
hideContentDivs();
});
$(function(){
$('#sub_1_2 a').click(function(e){
hideContentDivs();
var tmp_div = $(this).parent().index();
$('.sub_1_2 div').eq(tmp_div).show();
});
function hideContentDivs(){
$('.sub_1_1 div').each(function(){
$(this).hide();});
$('.sub_1_2 div').each(function(){
$(this).hide();});
}
hideContentDivs();
});
The rest can be found at https://jsfiddle.net/cL1xw2y5/