A
A
Anarchy2018-01-27 17:24:16
JavaScript
Anarchy, 2018-01-27 17:24:16

JS click counter. How to save the result?

Has a simple click counter

<script type="text/javascript">
    var clicks = 0;
    function onClick() {
        clicks += 1;
        document.getElementById("clicks").innerHTML = clicks;
    };
    </script>
    <button type="button" onClick="onClick()">Click me</button>
    <p>Clicks: <a id="clicks">0</a></p>

How to limit the number of clicks to one and how to save the result? At least write it to a text file on disk.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question