如何在等寬字型中顯示字串?


使用 JavaScript fixed() 方法顯示等寬字型,如同使用 <tt> 標記一樣。

示例

你可以嘗試執行以下程式碼以在等寬字型中顯示字串。

<html>
   <head>
      <title>JavaScript String fixed() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Hello world");
         alert(str.fixed());
      </script>
   </body>
</html>

更新時間:2020 年 5 月 20 日

119 次瀏覽

提升您的事業

完成課程獲得認證

開始
廣告
© . All rights reserved.