0

I'm trying to inject a string containing HTML elements into a div, but by the way, I only get it if the entire code is on one line.

This is what I am getting when push from the database and try to inject in div This is the problem

I tried to leave this code on one line and it worked This is how it should work

this is my code:

    var html = <%=data.long_description%>
   var html_string = html.replace("\n"," ")
    console.log(html_string)
  var iframe =document.getElementById("descript")
      iframe.innerHTML = html_string

The only problem is that I am using innerHTML, as I will not be able to do all this manually. Does anyone know how fix/leave all / HTML code in one line?

Tridib Dawn
  • 168
  • 1
  • 11
  • 1
    The first example is HTML encoded, thus it does not output what you want to. I has nothing to do with the lines or spaces. – Lain Nov 28 '19 at 23:00
  • do u know how can I do to inject this html in the div? – bruno fiverr Nov 28 '19 at 23:02
  • Check this: https://stackoverflow.com/questions/7394748/whats-the-right-way-to-decode-a-string-that-has-special-html-entities-in-it – Lain Nov 28 '19 at 23:06

0 Answers0