SHARE
TWEET

Untitled

a guest Jun 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3.   $('#navi a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
  4. });
  5. </script>
  6.      
  7. <ul id="navi">
  8.   <li><a href="#">About MHG</a></li>
  9.   <li><a href="#">Workout Programs</a></li>
  10.   <li><a href="#">Fitness Tips</a></li>
  11.   <li><a href="#">Contact Us</a></li>          
  12.   <li><a href="#">Read Our Blog</a></li>
  13. </ul>
  14.      
  15. <ul id="navi">
  16.     <li><a class="menu" href="#">About MHG</a></li>
  17.     <li><a class="menu" href="#">Workout Programs</a></li>
  18.     <li><a class="menu" href="#">Fitness Tips</a></li>
  19.     <li><a class="menu" href="#">Contact Us</a></li>          
  20.     <li><a class="menu" href="#">Read Our Blog</a></li>
  21.   </ul>
  22.      
  23. $('a.menu').click(function(){
  24.     $('a.menu').removeClass("active");
  25.     $(this).addClass("active");
  26. });
  27.      
  28. $("#navi a").live("click", function(){
  29.   $("#navi a").removeClass("active");
  30.   $(this).addClass("active")
  31. });
  32.      
  33. $('a.menu').hover(
  34.  
  35. function () {
  36.     $(this).addClass("active");
  37. },
  38.  
  39. function () {
  40.     $('a.menu').removeClass("active");
  41. });
  42.      
  43. <div id="nav">
  44.     <ul>
  45.         <li class="active"><a href="index.php">Index</a></li>
  46.         <li><a href="about.php">About</a></li>
  47.         <li><a href="member.php">Member</a></li>
  48.         <li><a href="project.php">Project</a></li>
  49.         <li><a href="activity.php">Activity</a></li>
  50.     </ul>
  51. </div>
  52.      
  53. $(function () {
  54.     let url = window.location.href.substr(window.location.href.lastIndexOf("/") + 1);
  55.     $("#nav ul li a").each(function () {
  56.         if ($(this).attr("href") == url || $(this).attr("href") == '') {
  57.             $(this).closest('li').addClass("active");
  58.         }
  59.     })
  60. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top