Skip to content

Instantly share code, notes, and snippets.

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 alanwsmith/ea375cea94e6e16809033999e924ab43 to your computer and use it in GitHub Desktop.
Save alanwsmith/ea375cea94e6e16809033999e924ab43 to your computer and use it in GitHub Desktop.
<!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