【问题标题】:Placeholder text not appearing in textarea占位符文本未出现在文本区域中
【发布时间】:2013-04-21 05:40:43
【问题描述】:

我知道这里有人可以帮助我。我已经查看了关于同一主题的所有论坛,但也许有人可以帮助我的具体情况。占位符没有出现在我的文本区域中。代码如下:

<fieldset class="contactFormDetails">
    <input type="text" name="input-name" placeholder="Name" />
    <input type="text" name="input-mail" placeholder="Subject" />
</fieldset>
<fieldset class="contactFormMessage">
    <textarea name="input-message" placeholder="Type your message here"></textarea>
</fieldset>
<fieldset class="contactFormButtons">
    <input type="submit" value="Send" />
</fieldset>

【问题讨论】:

标签: html class textarea placeholder fieldset


【解决方案1】:

你用的是什么浏览器?旧版本的 IE 不支持 placeholder 属性。

在此处查看您的浏览器版本是否支持它:http://caniuse.com/input-placeholder

在这里查看:https://stackoverflow.com/a/13281620/1846192 一个 jQuery 插件,它增加了对旧 IE 版本中占位符文本的支持,并且在您提交表单时不会将占位符文本作为值提交。

【讨论】:

    【解决方案2】:

    你意识到你可以做到这一点吗?

    <textarea name="input-message" placeholder="Type your message here"></textarea>
    

    【讨论】:

    • 这不等同于占位符文本。您的解决方案要求用户在输入自己的文本之前突出显示并删除文本,而占位符文本会在您开始输入文本区域时自动消失。此外,此解决方案在发布表单时涉及更多工作,因为如果用户没有输入任何内容,则会提交值“在此处输入您的消息”,然后需要在服务器上处理。
    • @betterthanlife 原来的标记是正确的,然后检查你的 css 看看它是隐藏它还是设置为白色?
    猜你喜欢
    • 2011-05-09
    • 2013-07-07
    • 2011-06-28
    • 2017-10-03
    • 2013-09-15
    • 2015-10-25
    • 2021-10-31
    • 2012-02-06
    • 2015-06-05
    相关资源
    最近更新 更多