问题
I'm using the following code to generate a textarea
tag:
<%= text_area_tag :comment, '', autocomplete: "off", class: "form-control", placeholder: "Your Comment" %>
When rendered, it produces the following HTML:
<textarea name="comment" id="comment" autocomplete="off" class="form-control" placeholder="Your Comment"></textarea>
I know that if there is some text between <textarea>
and </textarea>
, the placeholder
won't show up, but in my case, there is nothing in-between, as it is clear from rendered HTML. So how can I put a placeholder
text for textarea
?
回答1:
The html seems to be valid to me.
<textarea name="comment" autocomplete="off" class="test" id="moretest" data-value="moretest" placeholder="snowman or iceman?"></textarea>
来源:https://stackoverflow.com/questions/29766232/how-to-insert-placeholder-text-in-text-area-tag-in-rails