chan.dev/ lessons/ epicreact

Create a User Interface with Vanilla JavaScript and DOM

We’re starting this adventure with a blank HTML file. So you know that I’ve got tricks up my sleave.

That’s all the markup that we need. Let’s jump into the script.

That’s all for the script. Let’s see what that did in the browser.

We now have:

<body>
<div id="root"></div>
<script type="module">
const rootElement = document.getElementById('root')
const element = document.createElement('div')
element.textContent = 'Hello JavaScript'
element.className = 'greeting'
rootElement.appendChild(element)
</script>
</body>