如何附加(或其他方法)大量 HTML 代码? [英] How To Append (Or Other Method) a Lot of HTML Code?
本文介绍了如何附加(或其他方法)大量 HTML 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要附加很多 HTML 代码.为了提高可读性,我不想将所有内容都写在一行中,而是将它们拆分为常规 HTML.那将是 15 个新行之类的东西.问题是 JavaScript 不允许我这样做.
var target = $('.post .comment_this[rel="' + comment_id + '"]').parent().parent();target.append('<div class="回复"><p>...</p><img src="" alt=""/>
');
基本上,我需要在那个地方添加 HTML.
我也需要添加一些变量.
解决方案
target.append(' <div class="replies">'+'<p>...</p>'+'<img src="" alt=""/>'+'</div>');
或
target.append(' \<p>...</p>\<img src="" alt=""/>\');
I need to append a lot of HTML code. To improve readability, I don't want to write that all in one line, but split them as regular HTML. That would be like 15 new-lines or something. The problem is that JavaScript doesn't allow me to do that.
var target = $('.post .comment_this[rel="' + comment_id + '"]').parent().parent();
target.append('
<div class="replies">
<p>...</p>
<img src="" alt="" />
</div>
');
Basically, I need to add HTML in that place.
I need to add some variables too.
解决方案
target.append(' <div class="replies">'+
'<p>...</p>'+
'<img src="" alt="" />'+
'</div>'
);
or
target.append(' <div class="replies">\
<p>...</p>\
<img src="" alt="" />\
</div>'
);
这篇关于如何附加(或其他方法)大量 HTML 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文