如何在提示框中添加换行

您所在的位置:网站首页 alert里面的内容换行 如何在提示框中添加换行

如何在提示框中添加换行

2024-07-10 19:43| 来源: 网络整理| 查看: 265

如何在提示框中添加换行

为了在 提示框 的内容中添加换行,我们将使用 \n 反斜杠(n)符号。

示例1: 此示例在 提示框 的文本中的两行之间添加 \n 。

    GeeksforGeeks

    Click on the button to pop     alert box with added new line.

    click here     var text =         "This is line 1\nThis is line 2";            function gfg_Run() {         alert(text);     }

输出:

如何在提示框中添加换行

示例2: 这个示例在文本 警报框 的3行之间添加了 \n 。

    GeeksForGeeks

    Click on the button to pop     alert box with added new line.

    click here     var text =         "This is first line\nThis is "+         "middle line\nThis is last line";            function gfg_Run() {         alert(text);     }

输出:

如何在提示框中添加换行



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3