Created
November 9, 2012 21:34
-
-
Save timkg/4048408 to your computer and use it in GitHub Desktop.
Slightly altered code from page 3 of Async Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var clickCount = 0, link; | |
| link = document.getElementById('masochist') | |
| link.innerHTML = 'How many times can you click me?'; | |
| link.onclick = function(){ | |
| clickCount++; | |
| link.onclick = function(){ clickCount++; }; | |
| start = new Date(); | |
| while (new Date() - start < 5000) {} | |
| console.log(clickCount); // this will always be 1 | |
| link.innerHTML = 'You clicked me ' + clickCount + ' times. Ow!'; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment