Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

javascript - 有什么方法可以从字符串中删除所有行并仅放置一行?(Is there any way to remove all lines from a string and put only one line?)

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.

(我正在尝试将包含html元素的字符串注入div,但是顺便说一句,我只在整个代码都在一行上的情况下才得到它。)

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

(这是从数据库推送并尝试注入div时得到的结果, 这就是问题所在)

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("
"," ")
    console.log(html_string)
  var iframe =document.getElementById("descript")
      iframe.innerHTML = html_string

Only problem is that I am using innerHTML, as I will not be able to do all this manually.

(唯一的问题是我正在使用innerHTML,因为我将无法手动完成所有这些操作。)

Does anyone know how fix / leave all / html code in one line?

(有谁知道如何在一行中修复/保留所有/ html代码?)

  ask by bruno fiverr translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...