Appending large block of html with append()

后端 未结 11 936
-上瘾入骨i
-上瘾入骨i 2021-01-31 10:09

Im trying to append a large block of text using jquery\'s append().

$(\'#add_contact_btn\').click(function(event) {
    event.preventDefault();

    var large =         


        
11条回答
  •  盖世英雄少女心
    2021-01-31 10:35

    Another alternative is Template literals with back-ticks:

    var large = `some long text here
    some long text here
    some long text here`;
    

    It's a fairly new syntax and not supported in IE though.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

提交回复
热议问题