0

In the code below, if .blink is clicked .nclicks is counted. But on reloading the page the value of .nclicks returns back to 0 .I would like to maintain the number of clicks reached even after reload. How do I do that??

<p>clicks <a id="nclicks">0</a></p>
<a href="#" class="blink" onclick="countv();return false;" >true</a>


<script type="text/javascript">
var nclicks = 0;
function countv() {
    nclicks += 1;
    document.getElementById("nclicks").innerHTML = nclicks + '';
};
</script>
Kojo Amakye
  • 49
  • 1
  • 8

1 Answers1

1

Client-side only, you need localStorage.

See this thread :

setting a variable in local storage

Community
  • 1
  • 1
FLX
  • 2,626
  • 4
  • 26
  • 57