gpt4 book ai didi

javascript - Jquery 使用多行追加

转载 作者:行者123 更新时间:2023-12-02 20:48:10 27 4
gpt4 key购买 nike

我一直在开发一个项目,该项目使用从另一个站点调用的 ASP.NET 动态创建 JavaScript 文件。

这个 jquery javascript 文件附加了一个 div 并用相当大的 HTML 段填充它,为了做到这一点,我需要将该段转换为字符串,如下所示:

$(document).ready(function(){   
var html = "Giving this magazine such a lofty epithet may seem a bit presumptuous, but for a non scientifically trained outsider this magazine offers a fresh and challenging look at the fast paced world of science that doesn't shy away from humor and the use of terms and ideas that may require its readers to go online and define a term. And in some cases it may inspire the reader to pick up a book on science by such greats as Hawking and Greene in order to better grasp some of the concepts dealing with time, space and atoms. This magazine isn't dumbed down. It includes well placed and efficient illustrations to help explain some of the more abstract points. It is not designed in the way popular magazinea are, in so much as they only touch upon a topic in the simplest manner and then move on before the audience is lost. Yet this magazine keeps the attention of the reader by combining explanatory notes that help people with no background knowledge have some grasp of the topic and by using humor and well written articles to clearly make their points. <br />For a magazine with a serious and well researched list of topics having small cartoons the likes of the New Yorker shows how comfortable this magazine is with itself. From the moment I picked up this magazine for the first time I felt like every word I read mattered and was worth my time to read. (Not true of many other magazines) American Scientist may not have the audience of Discover or National Geographic, nor is it as accessible as said titles, but for those with a true interest in science willing to challenge themselves and commit to real learning this magazine may be a perfect fit. At $4.95 it is certainly worth it to pick a copy on the news stand and try it out."

$("#divname").append(html);
});

正如您所看到的,该段将非常大,我无法知道它有多大,因为它是根据用户在请求中定义的 reviewID 从我的数据库动态生成的。

要插入到 div 中的 html 是一个评论列表,由循环列表的转发器使用 asp.net MVC 生成。 (如果这有助于让您了解我在做什么)。

有什么办法可以将这一大段变成一个可以插入到附加脚本中的字符串吗?

谢谢

最佳答案

关于javascript - Jquery 使用多行追加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/574530/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com