Answers for "show a tag as a string in html"

0

html tag in string

var element = "<div id='whatever'>Hello</div>"
Posted by: Guest on March-11-2022
0

show html string in p tag

const str = `<div>
  <p>1st p tag</p>
  <p>2nd p tag</p>
</div>`

let doc = new DOMParser().parseFromString(str, 'text/html')

console.log(
  doc.querySelector('p').textContent
)
Posted by: Guest on November-25-2020

Browse Popular Code Answers by Language