如何在rails中的text_area_tag中插入占位符文本?

时间:2015-04-21 07:59:50

标签: html ruby-on-rails textarea placeholder

我使用以下代码生成textarea代码:

<%= text_area_tag :comment, '', autocomplete: "off", class: "form-control", placeholder: "Your Comment" %>

渲染时,会生成以下HTML:

<textarea name="comment" id="comment" autocomplete="off" class="form-control" placeholder="Your Comment"></textarea>

我知道如果<textarea></textarea>之间有一些文字,则placeholder会出现,但就我而言,中间没有任何内容,从渲染的HTML中可以清楚地看到。那么如何为placeholder添加textarea文字?

1 个答案:

答案 0 :(得分:4)

html似乎对我有用。

&#13;
&#13;
<textarea name="comment" autocomplete="off" class="test" id="moretest" data-value="moretest" placeholder="snowman or iceman?"></textarea>
&#13;
&#13;
&#13;