There are at least three questions in the code:
- Perhaps you are repeating some text nodes that do not have a method
.querySelector()
. - You do not initialize your loop iteration variable
for
i
- You have an undeclared variable
lineBoxList
that you are trying to use.
You can simplify things by simply using .querySelectorAll()
and letting the selector do more work for you.
function addToppingsToAll (toppings) {
var toppingItems = document.querySelectorAll("#PizzaBoxHolder h6");
for (var i = 0; i < toppingItems.length; i++) {
toppingItems[i].textContent = "You have " + toppings " on your pizza";
}
}
source
share