Html 为什么我的 textarea 的占位符不显示?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10585759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why isn't my textarea's placeholder showing up?
提问by Claire
I am using placeholders for all my form elements and it's showing up in them all apart from the textarea. Just looked at it in safari now, and have realised that my input of type="number" isn't showing the placeholder either.
我正在为我的所有表单元素使用占位符,并且除了 textarea 之外,它都显示在其中。现在刚刚在 safari 中查看它,并意识到我的 type="number" 输入也没有显示占位符。
The page is hereand you need to click the 'book now' link at the top of the page.
该页面在这里,您需要单击页面顶部的“立即预订”链接。
My html:
我的html:
<form id="booking" action="single-workshops.php">
<input type="text" required="required" placeholder="name"/><br />
<input type="text" required="required" placeholder="your phone number"/><br />
<input type="email" required="required" placeholder="email"/><br />
<input type="number" required="required" placeholder="how many in your party" /><br />
<textarea rows="5" cols="30" placeholder="enter optional message">
</textarea><br />
<input type="button" value="submit"/>
</form>
回答by PeeHaa
Because you have something as text in your textarea with a linebreak in it.
因为你的 textarea 中有一些文本,其中有一个换行符。
<textarea rows="5" cols="30" placeholder="enter optional message">
</textarea><br />
Should be:
应该:
<textarea rows="5" cols="30" placeholder="enter optional message"></textarea><br />