How do I insert an HTML element into append ()?

  • 0
    In general, how do you make it possible to insert an HTML tag and a variable into append ()?
    Like this: element.append ("& lt; div & gt;" + variable + "div")
    But the way I showed it does not work
    JavaScript Anonymous, Nov 28, 2019

  • 2 Answers
  • 0
    const wrapper = document.querySelector('.wrapper')
    let index = 8
    let div = document.createElement('div')
    div.textContent = index

    wrapper.append(div)
    Anonymous

  • 0

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!