Created
February 4, 2014 19:44
-
-
Save jhickman/8810866 to your computer and use it in GitHub Desktop.
IE innerHtml issue
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
<body> | |
<div class='outer'></div> | |
<script> | |
var outer = document.querySelector('.outer'); | |
var b = document.createElement('BUTTON'); | |
// setup event handlers | |
b.innerHTML = "Click me"; | |
function generateTheHtml() { | |
return'<div class="one"><div class="two">inside</div></div>'; | |
} | |
function refreshIt() { | |
outer.innerHTML = generateTheHtml(); | |
outer.querySelector('.two').appendChild(b); | |
} | |
// add for first time | |
refreshIt(); | |
// later, when needed, run again | |
refreshIt(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment