如何附加(或其他方式)HTML code的很多吗? [英] How To Append (Or Other Method) a Lot of HTML Code?

查看:139
本文介绍了如何附加(或其他方式)HTML code的很多吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要追加大量的HTML code的。为了提高可读性,我不想说写在一个线,但它们分割为普通的HTML。这就好比15个新的线什么的。问题在于JavaScript不容许我这样做。

  VAR的目标= $('后.comment_this [相对=+ COMMENT_ID +']')父()父()。target.append('
    < D​​IV CLASS =回复>
        < P> ...< / P>
        &所述; IMG SRC =ALT =/>
    < / DIV>
');

基本上,我需要在那个地方添加HTML。

我需要添加一些变量了。


解决方案

  target.append('< D​​IV CLASS =回复>'+
            '< P> ...< / P>'+
            '&所述; IMG SRC =ALT =/>'+
        '< / DIV>'
    );

  target.append('< D​​IV CLASS =回复> \\
            < P> ...< / P> \\
            &所述; IMG SRC =ALT =/> \\
        < / DIV>'
    );

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 code的很多吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆