fixed()

优质
小牛编辑
127浏览
2023-12-01

描述 (Description)

此方法使字符串以固定间距字体显示,就像它在标记中一样。

语法 (Syntax)

其语法如下 -

string.fixed( )

返回值 (Return Value)

返回带有《tt》标记的字符串。

例子 (Example)

请尝试以下示例。

<html>
   <head>
      <title>JavaScript String fixed() Method</title>
   </head>
   <body>
      <script type="text/javascript">
         var str = new String("Hello world");
         alert(str.fixed());
      </script>
   </body>
</html>

输出 (Output)

<tt>Hello world</tt>