开发者

Have problem with multi-line string in javascript

This works:

alert('foo\
   开发者_开发百科      bar'
)

But this is causing syntax error:

t='test';
alert('<tr><td><b>' + t + '</b></td>\ 
                    <td></td><td>')

error is:

SyntaxError: unterminated string literal

They two should be the same thing, why the first one works, while the second fails?


You have a trailing space after your backslash in the second example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜