Make your menu item active using this simple jquery
Today we will make a navigation menu item active using a very simple jQuery!
Copy the following code and paste it before </head>
Save your Template!
Hey! Did you find this tutorial useful? Share your thoughts by leaving a comment below!
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
DemoJScript
Go to Blogger » Template » Backup your Template » and Edit HTMLCopy the following code and paste it before </head>
<script>
jQuery(document).ready(function($){
var url = window.location.href;
$('#header li a[href="'+url+'"]').addClass('active');
});
</script>
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!
0 Comments
Be the first to comment