0

I have a working JS script allowing me to insert some HTML elements. Now I'm looking to put the element to be inserted into a new file for my code to be cleaner and more flexible. I've read that I could use the insertAdjacentElement but I'm not sure I understand the process.

Is there a way of doing so?

let c = document.querySelectorAll("b > span > a");
let final = [];
for (elt of c) {
  if (elt.href.startsWith("http://something")) {
    final.push(elt.text);
    elt.insertAdjacentHTML(
      "afterend",
      `
            <div>
                <textarea
                    name="name"
                    cols=70
                    rows=2
                    wrap="hard"
                    style="vertical-align:text-top;color:black;font-family:sans-serif;resize:none;border-color:#EEEEEE">
                    ${elt.text}</textarea>
            <div/>
        `
    );
  }
}
Raghul SK
  • 1,256
  • 5
  • 22
  • 30
Grégoire de Kermel
  • 434
  • 2
  • 8
  • 22

0 Answers0