Created
March 3, 2020 06:40
-
-
Save sontd-0882/2747f1aeac6b0e7f7124987823d5b2cb to your computer and use it in GitHub Desktop.
Listen child event from document
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
| document.addEventListener('click', (event: Event) => { | |
| const target = event.target as Element; | |
| const button = target.closest('.btn'); | |
| if (!button) return; | |
| const color = window | |
| .getComputedStyle(button) | |
| .getPropertyValue('background-color'); | |
| button.classList.add('ripple'); | |
| setTimeout(() => button.classList.remove('ripple'), 700); | |
| console.log('is .btn?', !!target.closest('.btn')); // eslint-disable-line | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment