如何在 JavaScript 警报中添加换行符?
要向 JavaScript 警报添加换行符,请使用“\r
”在以下示例中,我们将看到如何在 JavaScript 警报中显示文本。
示例
<html> <body> <script> function DisplayAlert() { var newLine = "\r
" var msg = "Showing how to add line break." msg += newLine; msg += "Line Break can be easily added in JavaScript."; msg += newLine; msg += "Simply Easy Learning"; msg+= newLine; msg += "TutorialsPoint.com"; alert(msg); } </script> <input type = "button" value = "Click" onclick = "DisplayAlert()" /> </body> </html>
广告