1

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();
Huzaifa
  • 193
  • 1
  • 7

0 Answers0