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 に答える