How to insert placeholder text in text_area_tag in rails?

匆匆过客 提交于 2021-01-27 12:19:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!