Can't add new lines in JavaScript alert Box?

前端 未结 2 1405
自闭症患者
自闭症患者 2021-01-24 10:45

I\'m generating a string in PHP and then eventually passing this string into a JavaScript alert box, my problem is I actually can\'t add line breaks in my alert box.

My c

2条回答
  •  粉色の甜心
    2021-01-24 11:20

    You need to change $str to

    $str = "This is a string\\n";
    

    so that the \n gets passed to the JavaScript.

提交回复
热议问题