如何在Rails的text_area_tag中插入占位符文本? [英] How to insert placeholder text in text_area_tag in rails?

查看:49
本文介绍了如何在Rails的text_area_tag中插入占位符文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来生成 textarea 标记:

I'm using the following code to generate a textarea tag:

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

渲染后,它会产生以下HTML:

When rendered, it produces the following HTML:

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

我知道,如果< textarea> </textarea> 之间存在一些文本,则 placeholder 不会显示向上,但就我而言,两者之间没有任何关系,从呈现的HTML可以清楚地看出.那么如何为 textarea 放置 placeholder 文本?

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?

推荐答案

html似乎对我有效.

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>

这篇关于如何在Rails的text_area_tag中插入占位符文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆