The menu is currently displayed on the left side without any issues. My next task involves implementing a back button functionality. When a user clicks from Demo1 to Demo 1.1, additional options like Demo 1.1.1 and Demo 1.1.2 will appear. To facilitate navigation, I plan to include a back button at the top of the menu structure:
//back
Demo1->Demo 1.1
//dropdown
Demo 1.1.1
Demo 1.1.2
Demo 1.1.3
Demo 1.1.4
Note: The menu is fully dynamic, hence static values are to be avoided.
$('.menu-item-has-children .sub-menu').css({
'left': '-320px'
});
$('.menu-item-has-children > a').click(function() {
//alert('hello');
var positionMenu = $(this).parent().attr('id');
//console.log(positionMenu);
$('.menu-item-has-children[id=' + positionMenu + '] > .sub-menu').css({
'left': '0px'
});
var pMenu1 = $(this).text();
console.log(pMenu1);
$('.secondary').prepend(pMenu1);
});
ul {
padding-left: 0;
}
.secondary {
z-index: 99;
background: #f8f8f8;
-webkit-box-shadow: 0 8px 24px rgba(229, 228, 230, 0.4);
box-shadow: 0 8px 24px rgba(229, 228, 230, 0.4);
-webkit-transition: left 0.2s ease, width 0.2s ease;
transition: left 0.2s ease, width 0.2s ease;
border-right: 1px solid #eaedf1;
position: fixed;
top: 0;
height: 100%;
padding: 12px;
width: 320px;
}
.menu li {
padding-bottom: 10px;
padding-left: 23px;
list-style: none;
}
.menu-item-has-children>a {
position: relative;
display: block;
}
.menu-item-has-children .sub-menu {
width: 100%;
height: 100%;
padding-top: 40px;
background: #f8f8f8;
list-style: none;
position: absolute;
top: 0;
left: 0;
transition: left .3s;
z-index: 10;
}
.menu-item-has-children>a::after {
display: inline-block;
vertical-align: middle;
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f054";
position: absolute;
right: 05px;
top: 0px;
font-size: 12px;
}
<script src="https://kit.fontawesome.com/97446b8f60.js" crossorigin="anonymous"></script>
<div class="secondary">
<ul id="menu-inner-page-menu" class="menu">
<li>Home</li>
<li id="menu-item-204" class="menu-item-has-children"><a href="#">Demo1</a>
<ul class="sub-menu">
<li id="menu-item-304" class="menu-item-has-children"><a href="#">Demo 1.1</a>
<ul class="sub-menu">
<li><a href="">Demo 1.1.1</a></li>
<li><a href="">Demo 1.1.2</a></li>
<li><a href="">Demo 1.1.2</a></li>
</ul>
</li>
<li id="menu-item-305"><a href="">Demo 1.2</a></li>
<li id="menu-item-306"><a href="">Demo 1.3</a></li>
<li id="menu-item-307"><a href="">Demo 1.4</a></li>
</ul>
</li>
<li id="menu-item-205" class="menu-item-has-children"><a href="#">Demo2</a>
<ul class="sub-menu">
<li id="menu-item-315"><a href="">Demo 2.1</a></li>
<li id="menu-item-316"><a href="">Demo 2.2</a></li>
</ul>
</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
The output is successfully being logged in the console.
https://i.sstatic.net/2Vxy6.png
The output is also visible in the HTML view source:
https://i.sstatic.net/oCPN0.png
Now, how can the output be made clickable?