Add class active on page refresh jquery

In this post you will learn how to add class active on page refresh jquery only. Sometimes in a dynamic page we have only one single page for menu markup. Its not possible to add class “active” in a HTML method. There are lots of ways to do this. PHP does it well. But in this post we are going to accomplish this mission of adding class without having to touch on server side scripting. It can be done with simple few lines of jquery code.

How to add class active on page refresh jquery only

Below how the HTML script should be placed inside the HTML. Generally script files are kept at the bottom of the page to load fast. Load fast doesn’t mean your jquery will load fast. It means that when you keep the jquery file at the top, the rest of the HTML will not load until the jquery load first. This can messed up your design while loading. So its better to place the script at the bottom. But in this post we don’t have a lot of content so we added the jquery inside head tag.

Let me say that my last statement was not quite accurate. It places an "active" class both in the parent and the child one, which then seems to deactivate the parent, so that the dropdown is no longer expanding.