JavaScript 字串 - fixed() 方法



描述

此方法導致字串以等寬字型顯示,就像在<tt>標籤中一樣。

語法

其語法如下所示:

string.fixed( )

返回值

返回帶有<tt>標籤的字串。

示例

嘗試以下示例。

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

輸出

<tt>Hello world</tt>
javascript_strings_object.htm
廣告