// Leave the next line, the form must be assigned to a variable named 'form' in order for the exercise test to pass const form = document.querySelector('form'); const product = document.querySelector("#product"); const qty = document.querySelector("#qty"); const groceryList = document.querySelector('#list'); form.addEventListener("submit", function(evt){ evt.preventDefault(); const newLI = document.createElement("LI"); //innerHTML or innerText or textContent newLI.innerHTML = `${product.value}${qty.value}` groceryList.appendChild(newLI); product.value = "" qty.value = "" });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter