title: Is it possible to add a HTML element and all its values to localStorage?
body: <p>I'm building a little JavaScript game and I want to implement a score box.<br>
  What I'm trying to do is; each time the user wins, add a score of 5 to localStorage and display it in the score box. <br>
  If the user wins again, increment the score in localStorage +5 and display the updated score.</p>
  
  <p>I've created the scoreBox.
  I also set a score of 5 to local storage and each time the user wins, 5 is displayed in the scoreBox</p>
  
  <p>// Here is the score box</p>
  
  <pre class="lang-js prettyprint-override"><code>let scoreBox = document.createElement('button');
  scoreBox.className = "button-primary"
  scoreBox.disabled = "true"
  scoreBox.style.fontSize = "20px";
  game.appendChild(scoreBox);
  </code></pre>
  
  <p>// Here is how I set the score</p>
  
  <pre class="lang-js prettyprint-override"><code>if(typeof(Storage) !== "undefined") {
     localStorage.setItem('score', 5)
     let score = localStorage.getItem('score');
     scoreBox.innerText = score;
  } else {
    console.error('Local Storage not supported!')
  }
  </code></pre>
  
  <p>Now, the score is displayed each time the user wins, but if I refresh, the value of 5 in the scoreBox does not remain but it remains in localStorage.<br>
  My question now is how can I store the entire scoreBox, or rather how to make the scoreBox and its textContent remain in localStorage.</p>
  
  <p>I'm new with localStorage and I don't know If I did the right thing tho, I've researched but could not find a possible answer that best solves my problem. Is it possible to store an HTML Element in localStorage?</p>
  
  <p>The game is a simple number guessing game, demo here: <br><a href="https://bolajiayodeji.github.io/brain-gym/" rel="nofollow noreferrer">https://bolajiayodeji.github.io/brain-gym/</a></p>
  
  <p>Full source code here: <a href="https://github.com/BolajiAyodeji/brain-gym" rel="nofollow noreferrer">https://github.com/BolajiAyodeji/brain-gym</a> <br>
  PS: The scoreBox feature is what I'm working on, I've not added it yet to the demo.</p>
  
  <p>Thank you in advance!</p>