【问题标题】:Subscript into Placeholder of Input HTML Tag输入 HTML 标记占位符的下标
【发布时间】:2016-04-18 06:12:00
【问题描述】:

您好,我正在尝试在 html 输入标记的占位符中使用下标字符。

<input type="text" class="form-control" id="fi2" placeholder="Installed Power kW<sub>p</sub>">

但我得到了这个:Installed Power kW&lt;sub&gt;p&lt;/sub&gt;

如果我使用例如 supercript (sup) 一切正常...

有什么帮助吗?

最好的问候, 丹尼尔

【问题讨论】:

  • 你想输出什么?
  • 对不起...但我得到了这个:装机功率“kWp

标签: html input placeholder subscript superscript


【解决方案1】:

http://www.fileformat.info/info/unicode/char/209a/index.htm

你需要在网页中链接一些包含下标p的字体(这些字体在网站上列出来引用),然后,写:

<input type="text" class="form-control" id="fi2">
<script>
    var placeholderText = 'Installed Power kW\u209A';
    $("#fi2").attr('placeholder', placeholderText);
</script> 

【讨论】:

    【解决方案2】:

    这是不可能的。 HTML 属性中不能有 HTML 标记。

    您必须改用&lt;label&gt;

    仅供参考,这里是 MDN 网站关于placeholder 的使用说明:

    不要使用占位符属性代替元素。它们的用途不同:属性描述了表单元素的作用;也就是说,它指示期望什么样的信息,占位符属性是关于内容应该采用的格式的提示。在某些情况下,占位符属性永远不会向用户显示,因此没有它,表单必须是可以理解的。

    【讨论】:

      【解决方案3】:
      <input type=“text” class=“form-control” id=“fi2” placeholder=“Installed Power KWₚ”>
      

      我建议只复制/粘贴一个下标字符。这肯定不是一个长期或有效的答案,但它应该适合您的情况。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-03-13
        • 1970-01-01
        • 2021-11-24
        • 2016-05-18
        • 2012-05-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多