Sticky Top Navigation Menu using jQuery Plugin

Sticky Top Navigation Menu using jQuery Plugin

This is another tutorial for jQuery menu plugin that our navigation menu stick at the top of our page when the user scrolling down our created page. This plugin also provides other function that to know the user what they are currently viewing on the page corresponding to the stick navbar menu. Using CSS, the sticky navbar menu item will be highlighted on its corresponding ID when the user scrolling down our page in and out of view. First, load this jQuery script library and jQuery stickup plugin to your page. Copy and paste this before end of your BODY tag.
  1.     <script src="js/jquery.js"></script>
  2.     <script src="js/bootstrap.min.js"></script>
  3.         <script src="js/stickUp.min.js"></script>
Second, create a simple navigation menu.
  1.     <!-- START THE NAVBAR -->
  2.     <div class="navbar-wrapper">
  3.       <div class="container">
  4.       <div class="navwrapper">
  5.         <div class="navbar navbar-inverse navbar-static-top">
  6.           <div class="container">
  7.             <div class="navbar-header">
  8.               <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
  9.                 <span class="icon-bar"></span>
  10.                 <span class="icon-bar"></span>
  11.                 <span class="icon-bar"></span>
  12.               </button>
  13.               <a class="navbar-brand" href="#">Free Tutorials</a>
  14.             </div>
  15.             <div class="navbar-collapse collapse">
  16.               <ul class="nav navbar-nav">
  17.                 <li class="menuItem active"><a href="#home">Home</a></li>
  18.                 <li class="menuItem"><a href="#programming">Programming</a></li>
  19.                 <li class="menuItem"><a href="#mobile">Mobile</a></li>
  20.                 <li class="menuItem"><a href="#blog">Blog</a></li>
  21.                 <li class="menuItem"><a href="#one-pager">Articles</a></li>
  22.                 <li class="menuItem"><a href="#extras">Tutorials</a></li>
  23.                 <li class="menuItem"><a href="#wordpress">Contact</a></li>
  24.                 <li class="menuItem"><a href="#contact">Submit Code</a></li>    
  25.               </ul>
  26.             </div>
  27.           </div>
  28.         </div>
  29.       </div><!-- End Navbar -->
  30.       </div>
  31.     </div> <!-- END NAVBAR -->
Lastly, copy and paste this plugin then you're done.
  1.             <script type="text/javascript">
  2.               //initiating jQuery  
  3.               jQuery(function($) {
  4.                 $(document).ready( function() {
  5.                   //enabling stickUp on the '.navbar-wrapper' class
  6.                   $('.navbar-wrapper').stickUp({
  7.                               });
  8.                 });
  9.               });
  10.             </script>

Output


Result
Note: You can customize your menu whatever your desired design by changing the CSS. If you are interested in programming, we have an example of programs that may help you even just in small ways. Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment