JSFiddle - React, Tailwind, and code Playground

by Joe

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="btn">Click to Reload</button>
<div id="test2"><p id="p2">this is invisible text</p></div>

CSS

/* No need for JavaScript to initially hide the element which
   can cause the usre to see it momentarially before the JS runs.
   Set its default display to none instead.                      */
#test2 { display:none; }

JavaScript

$(document).ready(function(){

        // Check to see if this is a page reload or not by seeing if a value was placed
        // into localStorage from a previous page load
        if(localStorage.getItem("loadedEarlier")){
          // Page has already loaded earlier
          $("#test2").css("display","block");
        }
        
        $("#btn").click(function(){
          location.reload();
        });    
        
        // Place a value into localStorage
        localStorage.setItem("loadedEarlier", "no")        
});