Created
February 12, 2018 16:59
-
-
Save mbarkley/31f0cee37cddbf56249ae19c6d3b3dfb to your computer and use it in GitHub Desktop.
Event Firing POC
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> | |
<head> | |
<script> | |
function doClick() { | |
// May need cross-browser support | |
//var evt = document.createEvent("HTMLEvents"); | |
var evt = new Event("change"); | |
var element = document.getElementById("id-2"); | |
evt.initEvent("change", false, true); | |
element.dispatchEvent(evt); | |
alert("finished"); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="id-1" onclick="doClick();" style="width:100;height:100;background:black"> | |
</div> | |
<div id="id-2" onchange="alert('done');" style="width:100;height:100;background:red"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment