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..

78 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
  3. Nice post. I learn something totally new and challenging on blogs
    I stumbleupon on a daily basis. It will always be interesting to read content from other
    authors and practice a little something from other websites.

    Reply
  4. My brother suggested I might like this blog. He was
    once entirely right. This publish truly made my day.
    You can not imagine simply how so much time I had spent for this information! Thanks!

    Reply
  5. Today, while I was at work, my cousin stole my iPad and tested to
    see if it can survive a forty foot drop, just so she
    can be a youtube sensation. My iPad is now broken and she has 83 views.
    I know this is completely off topic but I had to share it with
    someone!

    Reply
  6. Hi there! This article couldn’t be written much better!
    Reading through this article reminds me of my previous
    roommate! He always kept preaching about
    this. I most certainly will send this article to him.
    Fairly certain he will have a good read. Thank you for sharing!

    Reply
  7. After checking out a number of the blog posts on your site, I really appreciate your technique of blogging.
    I saved it to my bookmark website list and will be checking back in the near future.
    Take a look at my web site as well and let me know your opinion.

    Reply
  8. I am extremely impressed with your writing skills as well
    as with the layout on your weblog. Is this a paid theme
    or did you modify it yourself? Either way keep up
    the nice quality writing, it is rare to see a nice blog like this
    one nowadays.

    Reply
  9. My partner and I stumbled over here coming from a different web page
    and thought I should check things out. I like what I see so i am just
    following you. Look forward to looking into your web
    page repeatedly.

    Reply
  10. Thanks for your personal marvelous posting! I certainly enjoyed reading it, you could be a great author.I will ensure that I
    bookmark your blog and will come back in the foreseeable future.
    I want to encourage yourself to continue your great posts, have a nice holiday weekend!

    Reply
  11. Write more, thats all I have to say. Literally, it seems as though you relied on the video to
    make your point. You obviously know what youre talking about, why waste your intelligence on just posting videos
    to your weblog when you could be giving us something enlightening to read?

    Reply
  12. I feel that is one of the so much significant info for me.
    And i’m glad reading your article. But wanna observation on few basic things, The site style is wonderful, the articles is truly great :
    D. Excellent task, cheers

    Reply
  13. Please let me know if you’re looking for a writer for your blog.
    You have some really great articles and I feel I would be a good asset.
    If you ever want to take some of the load off, I’d love to write some articles for
    your blog in exchange for a link back to mine. Please blast me an e-mail if interested.
    Many thanks!

    Reply
  14. Have you ever considered creating an ebook or guest authoring on other
    blogs? I have a blog centered on the same topics you discuss and would love to have you share some stories/information. I know my
    subscribers would enjoy your work. If you’re even remotely interested, feel free to send me an email.

    Reply
  15. Hey there! I know this is somewhat off topic but I was wondering which blog platform are
    you using for this site? I’m getting sick and tired of WordPress because I’ve had
    problems with hackers and I’m looking at options for another platform.
    I would be awesome if you could point me in the direction of a good platform.

    Reply
  16. Its like you read my mind! You seem to know so
    much about this, like you wrote the book in it or
    something. I think that you can do with some pics to drive the
    message home a bit, but instead of that, this is wonderful blog.
    An excellent read. I will certainly be back.

    Reply

Leave a Comment