I'm having a bit of trouble with my HTML code. Here's what it looks like:
<div class="side-button">
<a href="/first"> First Option <a>
</div>
<div class="side-button">
<a href="/second"> Second Option <a>
</div>
My goal is to make it so that when a user clicks on one of the blocks, it becomes active and can be highlighted with a different color.
In my jQuery script, I've been attempting to add the class active
to the clicked block:
jQuery(document).ready(function( $ ){
$(".side-button").bind('click', function () {
$(".side-button").removeClass("active");
$(this).addClass("active");
});
});
While this works while the next page is loading, after a redirect, the active
class is not remembered. How can I make sure that the class active
stays applied on the loaded page?