如何以等宽字体显示字符串?

htmljavascriptprogramming scripts

使用 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>

相关文章