let arr=[<b>hari</b>,<b>gc</b>]
let newarr=arr.join(" ")
let textnode=document.createTextNode(newarr)
let al = document.getElementById("neww");
$(textnode).insertBefore(al);
expected output: hari gc
what i get as the output:
<b>hari</b> <b>gc</b>
I tried using parse from npm HTML react parse..but it results in an error
plese help..
CodePudding user response:
You can write it via dangerouslySetInnerHTML like this
<div dangerouslySetInnerHTML={{ __html: yourHtmlString }} />
CodePudding user response:
let arr = ['<b>hari</b>', '<b>gc</b>']
let newarr = arr.join(" ")
let block = document.querySelector(".block");
block.innerHTML = newarr
<div ></div>