remain added class after refresh

I found this fiddle from other questions, and its good to use. The problem is the added class(.active) in button remove when refresh. How can I make it remain even I reload it.

FIDDLE

HTML

<div class="flr-wrap">
<ul>
    <li><a class="button active" data-rel="#content-a" href="#">a button</a></li>
    <li><a class="button" data-rel="#content-b" href="#">b button</a></li>
</ul>

<div class="flr-inner">
    <div class="container" id="content-a">
        AAA
    </div>
    <div class="container" id="content-b">
        BBB
    </div>
</div>

JS

    // set content on click
$('.button').click(function(e) {
    e.preventDefault();
    setContent($(this));
});

// set content on load
$('.button.active').length && setContent($('.button.active'));

function setContent($el) {
    $('.button').removeClass('active');
    $('.container').hide();

    $el.addClass('active');
    $($el.data('rel')).show();
}

Thanks in advance..

4 thoughts on “remain added class after refresh”

  1. Wonderful blog! Do you have any suggestions for aspiring writers?
    I’m planning to start my own website soon but I’m a little lost on everything.

    Would you propose starting with a free platform like WordPress or go for
    a paid option? There are so many options out there that I’m totally confused ..
    Any ideas? Thanks a lot!

    Reply
  2. Hi! This post could not be written any better! Reading this
    post reminds me of my old room mate! He always kept talking
    about this. I will forward this page to him. Pretty sure he will have a good read.
    Thanks for sharing!

    Reply

Leave a Comment