Defining a long string with javascript

This question already has an answer here:

  • Creating multiline strings in JavaScript 34 answers

  • 只要把在每行的最后仍然在字符串中

    str = "  The quick brown   // <---
    fox jumped over the log.";
    

    Easiest thing to do is to add a at the end of the lines:

    function test_str() {
      str = "  The quick brown 
      fox jumped over the log.";
      alert(str);
    }
    

    jsFiddle example


    尝试这个:

    str = " the quick brown foxrn" + 
      "fox jumped over the lazy dog";
    
    链接地址: http://www.djcxy.com/p/30438.html

    上一篇: Python中使用三重引号字符串的替代方法

    下一篇: 用javascript定义一个长字符串