How to used window local storage value in dynamically in href?

  html, javascript, jquery, local-storage

In the below html I have to change the ul li href value according to the selected country in window local storage value.

<ul>
  <li><a href="#">USA</a></li>
  <li><a href="#">India</a></li>
</ul>

<ul>
  <li>
    <a onclick="window.localStorage.setItem('country',JSON.stringify({'country':'USA'}))">USA</a>
  </li>
  <li>
    <a onclick="window.localStorage.setItem('country',JSON.stringify({'country':'India'}))">India</a>
  </li>
</ul>

Source: Ask Javascript Questions

LEAVE A COMMENT