How to make a div stay visable after refresh

29 Views Asked by At

After I make a div show, how do I keep it shown even after reloading?

$(document).ready(function() {
  $("#openButton").click(function(e) {
    e.preventDefault();
    $("#open").show();
    $(".OSboxColor").not("#open").hide();
  });

  $("#warningButton").click(function(e) {
    e.preventDefault();
    $("#warning").show();
    $(".OSboxColor").not("#warning").hide();
  });

  $("#closedButton").click(function(e) {
    e.preventDefault();
    $("#closed").show();
    $(".OSboxColor").not("#closed").hide();
  });
});
.green {
  color: white!important;
  font-size: 25px;
  display: block;
  height: 40px;
  background-color: green;
  font-weight: bolder;
}

.orange {
  color: white!important;
  font-size: 25px;
  display: block;
  background-color: orange;
  height: 40px;
  font-weight: bolder;
}

.red {
  color: white!important;
  font-size: 25px;
  display: block;
  background-color: red;
  height: 40px;
  font-weight: bolder;
}

.orange a {
  color: white!important;
}

.red a {
  color: white!important;
}

.green a {
  color: white!important;
}

#OSbox {
  width: 18%;
  float: right;
  border: 1px solid lightgray;
}

#OSboxText {
  font-size: .8vw;
  width: 80%;
  float: left;
  text-align: right;
  padding-top: 9px;
  padding-right: 5px;
  font-weight: bold;
}

#OSboxText a {
  padding: 0px;
  margin: 0px;
}

.OSboxColor {
  width: 20%;
  float: left;
  text-align: center;
}

.OSButton {
  color: white;
  font-weight: bolder;
  padding-right: 15px;
  padding-left: 15px;
  padding-top: 7px;
  padding-bottom: 7px;
  margin: 15px;
  cursor: pointer;
}
<div style="width:100%; display:;">
  <div id="OSbox">
    <div id="OSboxText"><a href="/Operating-Status/"><strong>Status:</strong></a></div>

    <div class="OSboxColor green" id="open" style="display:;"><a href="/Operating-Status/">✔</a></div>

    <div class="OSboxColor orange" id="warning" style="display:none;"><a href="/Operating-Status/">&#33;</a></div>

    <div class="OSboxColor red" id="closed" style="display:none;"><a href="/Operating-Status/">✖</a></div>
  </div>
</div>

<div style="display: flex; justify-content: center">
  <button style="background-color: green;" id="openButton" class="OSButton">Open</button>
  <button style="background-color: orange;" id="warningButton" class="OSButton">Warning</button>
  <button style="background-color: red;" id="closedButton" class="OSButton">Closed</button>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

0

There are 0 best solutions below