I'm trying to add more inputs using a button using JS and can't figure it out.
So, I have this code in my HTML:
<div id="ingredients" class="ingredients">
<h2 class="tk-freight-sans-pro">Ingredients</h2>
<input type="text" placeholder="Ingredient">
<input type="text" placeholder="Ingredient">
<input type="text" placeholder="Ingredient">
<br>
<button class="button" onclick="addIngredient();">Add Ingredient</button>
</div>
And my JS is here:
function addIngredient() {
var list = document.getElementById("ingredients")
list.innerHTML += "<input type="text" placeholder="Ingredient">"
}
Does anyone know what's going on or what I need to do? Thanks!