Make your menu item active using this simple jquery

Today we will make a navigation menu item active using a very simple jQuery!

Introduction

This simple jQuery will check the URL of the current page and see if it matches with the URLs in the menu, then an "active" class will be added to the menu item automatically.

External Scripts

Jquery Library v1.0.0 or higher (?)

Live Demo

Demo

JScript

Go to Blogger » Template » Backup your Template » and Edit HTML
Copy the following code and paste it before </head>
<script>
jQuery(document).ready(function($){
var url = window.location.href;
$(&#39;#header li a[href=&quot;&#39;+url+&#39;&quot;]&#39;).addClass(&#39;active&#39;);
});
</script>
Save your Template!

Final Words

So that's it! Don't hesitate to ask. Enjoy blogging!
Hey! Did you find this tutorial useful? Share your thoughts by leaving a comment below!

Rate This Article

Thanks for reading: Make your menu item active using this simple jquery, Stay tune to get latest Blogging Tips.

Getting Info...

Post a Comment

Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.