Created
September 6, 2018 20:05
-
-
Save rniwa/6c502dca3e16d5816db7958ce7bab4d7 to your computer and use it in GitHub Desktop.
Dispatching click event on a radio button and observing the event phase inside a change event listener
This file contains 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<input type="radio"> | |
<script> | |
const input = document.querySelector('input'); | |
const clickEvent = new MouseEvent('click', {button: 0, which: 1}); | |
input.addEventListener('change', () => { | |
alert(clickEvent.eventPhase); | |
}) | |
input.dispatchEvent(clickEvent); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment