如何在 JavaScript 警報框中提供新行?


若要在 JavaScript 警報框中新增新行,請使用 “

alert("Line One
Line Two");

例項

你可以嘗試執行以下程式碼在 JavaScript 警報框中新增新行

即時演示

<html>
   <head>
      <script>
         <!--
            function Warn() {
               alert ("This is a warning message!
This is a new line.");                document.write ("This is a warning message!");             }          //-->       </script>    </head>    <body>       <p>Click the following button to see the result: </p>       <form>          <input type="button" value="Click Me" onclick="Warn();" />       </form>    </body> </html>

更新於: 08-Jan-2020

612 次瀏覽

開啟你的 職業生涯

透過完成本課程來獲得認證

開始學習
廣告