我使用以下代码生成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
文字?
答案 0 :(得分:4)
html似乎对我有用。
<textarea name="comment" autocomplete="off" class="test" id="moretest" data-value="moretest" placeholder="snowman or iceman?"></textarea>
&#13;