I'm pretty new to javascript and trying some things to learn. I'm however getting one issue and can't seem to figure it out.
If I'm looking trough the nodelist with document.querySelectorAll(".product .actions .stock.outofstock")
I get 10 results back:
I want to replace the inside from all these elements to something new.
I tried using the following:
let outofstock = document.querySelectorAll(".product.actions.stock.outofstock").innerHTML;
document.querySelectorAll(".product.actions.stock.outofstock").innerHTML= outofstock.replace(/Out of stock/g,'<i class="icon-negative"></i>Sold out');
That didnt work and gives me the following error:
however when I use the following code it works, but for only the first element:
let outofstock = document.querySelector(".product.actions.stock.outofstock").innerHTML;
document.querySelector(".product.actions.stock.outofstock").innerHTML= outofstock.replace(/Out of stock/g,'<i class="icon-negative"></i>Sold out');