Skip to content Skip to sidebar Skip to footer

How To Hide And Show Button After Page Reload

I am learning jQuery and I have issues on how to hide and show a button during page reload. I tried my code below, it hides and shows the button on click, but when the page loads,

Solution 1:

There seems to be a problem in how you test if the .followback-btn was pressed.

In your second jQuery example, try replacing this line:

localStorage.getItem('show') && $hidden.show();

With this:

if (localStorage.getItem('show')) {
    $hidden.show();
    $('.followback-btn').hide();
}

This means that if the show variable is set in the local storage, the .following-btn will be shown when the page loads, instead of the .followback-btn one.

Hope this helps.


Post a Comment for "How To Hide And Show Button After Page Reload"