新手问题 怎样设置输入框初始文字?

babywhy · May 21, 2013 · Last by babywhy replied at May 22, 2013 · 2667 hits

·<%= text_field_tag :search, params[:search]%>·比如想在输入框中添加“请输入”初始文字,应该怎样添加?

<%= text_field_tag :search, params[:search], :value => "请输入"%>

回复 1 楼 @jjzxcc 谢谢。

placeholder

用 placeholder 不要用 value

@jjzxcc 同样不建议用:value,要是用户粗心,就很麻烦

一般用于提示用户或用作示例的文字都用 placeholder,编辑已有的字段值就用 value。

6 Floor has deleted

没想到大家这么热情 真心谢谢你们!!@messiahxu @ch3n @chunlea @Martin91 DestinyDesigner

You need to Sign in before reply, if you don't have an account, please Sign up first.