Skip to content

Instantly share code, notes, and snippets.

@timothy
Created June 14, 2016 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothy/4cd7ba87a833140a06b608dcb059c681 to your computer and use it in GitHub Desktop.
Save timothy/4cd7ba87a833140a06b608dcb059c681 to your computer and use it in GitHub Desktop.
DOM Manipulation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DOM Manipulation</title>
</head>
<body>
<script type="text/javascript">
/**
* Add new DOM elements
*/
function adDnD(numOfDomElmnts) {
for (var i = 0; i < numOfDomElmnts; i++) {
document.getElementById('numbers').innerHTML += '<div id="item1' + i + '">' + i + '</div>';
document.getElementById('box').innerHTML += '<div id="item2' + i + '">boxes' + i + '</div>';
}
}
window.onload = function () {
adDnD(15);
}
</script>
<div id="box"></div>
<div id="numbers"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment