--- title: String.prototype.fixed() slug: Web/JavaScript/Reference/Global_Objects/String/fixed tags: - Deprecated - HTML wrapper methods - JavaScript - Method - Prototype - Reference - String translation_of: Web/JavaScript/Reference/Global_Objects/String/fixed ---
fixed()
メソッドは、文字列を等幅フォントで表示させる HTML の {{HTMLElement("tt")}} 要素を生成します。
str.fixed()
HTML の {{HTMLElement("tt")}} 要素を含む文字列です。
fixed()
メソッドは、文字列を <tt>
要素の中に、 "<tt>str</tt>
" のように埋め込みます。
下記の例は、 fixed
メソッドを使用して文字列の表示方法を変更します。
var worldString = '世界のみなさん、こんにちは!'; console.log(worldString.fixed()); // "<tt>世界のみなさん、こんにちは!</tt>"
仕様書 |
---|
{{SpecName('ESDraft', '#sec-string.prototype.fixed', 'String.prototype.fixed')}} |
{{Compat("javascript.builtins.String.fixed")}}