Skip to content

Instantly share code, notes, and snippets.

@pavelfeldman
Last active July 4, 2021 22:25
Show Gist options
  • Save pavelfeldman/5149547a0c5886805c1a2f8099aa2f55 to your computer and use it in GitHub Desktop.
Save pavelfeldman/5149547a0c5886805c1a2f8099aa2f55 to your computer and use it in GitHub Desktop.
<button id=submit>Submit</button>
<div id=log style='white-space: pre'></div>
<script>
const button = document.getElementById('submit');
button.addEventListener('mousedown', () => {
print('1. down');
Promise.resolve().then(() => print('2. down task ends'));
});
button.addEventListener('mouseup', () => {
print('3. up');
Promise.resolve().then(() => print('4. up task ends'));
});
button.addEventListener('click', () => {
print('5. click');
Promise.resolve().then(() => print('6. click task ends'));
});
const text = [];
function print(line) {
text.push(line);
document.getElementById('log').textContent = text.join('\n');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment