Created
July 25, 2022 20:18
-
-
Save alanwsmith/ea375cea94e6e16809033999e924ab43 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<script> | |
const theDivs = [ | |
{ | |
id: 'id1', | |
}, | |
{ | |
id: 'id2', | |
}, | |
] | |
function makeDivs() { | |
const wrapperDiv = document.getElementById('wrapper') | |
theDivs.forEach((theDiv) => { | |
const newDiv = document.createElement('div') | |
newDiv.innerHTML = theDiv.id | |
wrapperDiv.append(newDiv) | |
}) | |
} | |
window.addEventListener('DOMContentLoaded', (event) => { | |
makeDivs() | |
}) | |
</script> | |
</head> | |
<body> | |
<div id="wrapper"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment