div, h1, p, etc.)#theID, div#theID, etc.).theClass, p.theClass, etc.)document.querySelector/document.querySelectorAll.textContent/.innerHTMLconsole.logconsole.group/.groupEnd/.groupCollapsedonsubmit.preventDefault.target`Hi, ${name}`
<div class="person">
<h2 id="firstName">Han</h2>
<h2 id="lastName">Solo</h2>
<p>Made the Kessel Run in less than 12 parsecs</p>
<button>Click here to hire me!</button>
</div>
// Get all h2 elements with querySelectorAll. Returns a NodeList
const headings = document.querySelectorAll('.person h2')
console.log(headings)
// => [h2#firstName, h2#lastName]
// Get a single element with querySelector
const heading = document.querySelector('.person h2')
console.log(heading)
// => h2#firstName
// Do something when a click event occurs
const button = document.querySelector('button')
button.onclick((ev) => {
alert('clicked!')
console.log(ev.target)
// => button
})
Add form values to .details using document.createElement and appendChild, instead of innerHTML.
Break out some of this functionality into a separate function.
Do not hard-code the names of the fields in your JavaScript. Loop over all the elements in the form.