0

为什么当我有一个带有换行符的变量时 jQuery 不起作用:

这有效:

var text = "This is my text and it works fine";

这不会:

var text = "this is my text
            and it does not work";

有没有办法解决?我正在尝试创建一个包含数据库文本的变量,它可能包含换行符、标签...

4

2 回答 2

1

Try Below

var text = "this is my text";
   text += " and it does not work";

OR

var text = "this is my text" +
       " and it does not work";

OR

var text = "this is my text  \
       and it DOES  work now";
于 2013-05-06T14:17:51.323 回答
0

以下方式是正确的 -

var text = "this is my text " +
           "and it DOES  work now! ";

检查这个演示

于 2013-05-06T14:16:34.837 回答