Most of the developer has an issue to select active menu in the same header. So here we try with the following example. May be this example will help you, If you have any doubt or question you can comment us. We will reply you ASAP.
<ul id="menu"> <li><a href="https://www.blogger.com/home">Home</a></li> <li><a href="https://www.blogger.com/about">About us</a></li> <li><a href="https://www.blogger.com/contact">Contact us</a>>/li> </li> </ul>
Suppos here we click on Home menu. Then home li should be selected. My URL is : http://www.example.com/home
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function() { var currentURL=location.href; var arrURL=currentURL.split("/"); var currMenu=arrURL[3]; if (currMenu != "") { jQuery('#menu li a').each(function(idx, item){ var menuURL = jQuery(this).attr("href"); if (menuURL == currMenu) { jQuery(this).addClass("active"); } }); } }); </script>
<ul id="menu"> <li><a class="active" href="https://www.blogger.com/home">Home</a></li> <li><a href="https://www.blogger.com/about">About us</a></li> <li><a href="https://www.blogger.com/contact">Contact us</a>>/li> </li> </ul>
Introduction In the world of web development, selecting the correct framework is critical. Laravel and…
Introduction By enabling containerization, Docker has transformed the way software is built, deployed, and managed.…
Introduction Speed and efficiency are critical in the ever-changing world of web development. Effective caching…
Introduction Git, a popular version control system in software development, enables developers to track changes,…
Introduction Are you tired of grappling with tangled changes and unfinished work while using Git?…
Introduction Version control is essential in software development because it ensures that changes to a…