JSFiddle - React, Tailwind, and code Playground
by harifrais
HTML
<div class="faq"></div>
<div class="faq"></div>
<div class="faq"></div>
CSS
.red { color: red; }
JavaScript
const faqBoxes = document.querySelectorAll('.faq');
faqBoxes.forEach(box => {
const toggler = document.createElement('i');
toggler.textContent = 'Hallo';
toggler.className = 'red';
box.appendChild(toggler);
});
const parent = document.getElementsByClassName("faq")
console.log(parent)
while (parent.firstChild) {
parent.firstChild.remove()
}