JavaScript String fixed() 方法

  • JavaScript String fixed() 方法

    fixed()方法不是标准方法,并且可能无法在所有浏览器中按预期工作。fixed()方法用于将字符串显示为电传打字文本。此方法返回嵌入在<tt>标记中的字符串,如下所示:
    <tt>字符串</tt>
    HTML5中不支持<tt>标记。请改用CSS。
    实例:
    将文本显示为电传文字:
    var str = "Hello World!";
    var result = str.fixed();
    
    尝试一下
  • 浏览器支持

    IE/Edge Chrome FireFox Safari Opera
    方法
    fixed()
    支持
    支持
    支持
    支持
    支持
  • 语法

    string.fixed()
  • 参数值

    参数 描述
    没有
  • 技术细节

    项目 描述
    返回值: 嵌入在<tt>标记中的字符串
    JavaScript版本: ECMAScript 1
  • 更多例子

    相关方法的演示:
    var txt = "Hello World!";
    
    document.write("The original string: " + txt);
    document.write("<p>Big: " + txt.big() + "</p>");
    document.write("<p>Small: " + txt.small() + "</p>");
    document.write("<p>Bold: " + txt.bold() + "</p>");
    document.write("<p>Italic: " + txt.italics() + "</p>");
    document.write("<p>Fixed: " + txt.fixed() + "</p>");
    document.write("<p>Strike: " + txt.strike() + "</p>");
    document.write("<p>Fontcolor: " + txt.fontcolor("green") + "</p>");
    document.write("<p>Fontsize: " + txt.fontsize(6) + "</p>");
    document.write("<p>Subscript: " + txt.sub() + "</p>");
    document.write("<p>Superscript: " + txt.sup() + "</p>");
    document.write("<p>Link: " + txt.link("https://www.w3schools.com") + "</p>");
    document.write("<p>Blink: " + txt.blink() + " (works only in Opera)</p>");
    
    尝试一下