'How do I insertAdjacentHTML on querySelectorAll class? [duplicate]
I want to add HTML to all elements having same class (.testimonial-text). However Everytime I use querySelectorAll to define the elements, insertAdjacentHTML returns an error that say 'insertAdjacentHTML in not a function' . It works fine when I user querySelector (which targets only first element of the class) but again I want to target and insert html on every element of the class.
var testimonialText = document.querySelectorAll(".testimonial-text");
const testimonialTextBack = function () {
const html = `<p>Testing</p>`;
testimonialText.insertAdjacentHTML("beforeend", html);
};
testimonialTextBack();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
