Created
February 13, 2013 16:50
-
-
Save Rockncoder/4946017 to your computer and use it in GitHub Desktop.
A demo of Live DOM Objects
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
<h1>Live DOM Objects</h1> | |
<button onclick="runTest()">Run Test</button> | |
<div>#1</div> | |
<div>#2</div> | |
<script type="text/javascript"> | |
function runTest() { | |
var div, ndx, divs = document.getElementsByTagName("div"); | |
/* | |
This despite appearances is an endless loop | |
Execute with caution | |
*/ | |
debugger; | |
for(ndx=0; ndx < divs.length; ndx++){ | |
div = document.createElement("div"); | |
/* every time we add a div to the page, divs.length increases */ | |
document.body.appendChild(div); | |
debugger; | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment