Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <script> function clickCounter() { if(typeof(Storage) !== "undefined") { if (localStorage.clickcount) { localStorage.clickcount = Number(localStorage.clickcount)+1; } else { localStorage.clickcount = 1; } document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s)."; } else { document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage..."; } } </script> </head> <body> <p><button onclick="clickCounter()" type="button">Click me!</button></p> <div id="result"></div> <p>Click the button to see the counter increase.</p> <p>Close the browser tab (or window), and try again, and the counter will continue to count (is not reset).</p> </body> <!-- Mirrored from www.w3schools.com/html/tryit.asp?filename=tryhtml5_webstorage_local_clickcount by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 07:20:59 GMT --> </html>
Result:
Try it Yourself - © w3schools.com