admin管理员组文章数量:1336181
I have something like this
<input placeholder="something">
The default behavior is the placeholder text disappears when the user begins typing. How can I make it so the placeholder bees the actual content of the field and is editable?
Do I need javascript?
I have something like this
<input placeholder="something">
The default behavior is the placeholder text disappears when the user begins typing. How can I make it so the placeholder bees the actual content of the field and is editable?
Do I need javascript?
Share asked May 8, 2014 at 10:58 jopfrejopfre 5033 silver badges12 bronze badges 3-
If it’s a useful placeholder, it’s hardly a useful default value. What are you really trying to acplish? To set a default (initial) value, just use the good old
value
attribute. Then a placeholder would probably be just confusing. – Jukka K. Korpela Commented May 8, 2014 at 11:04 - Why do you want to edit the placeholder value? – Jai Commented May 8, 2014 at 11:09
- Yep you are right I didn't want a placeholder, I wanted value. Thanks – jopfre Commented May 8, 2014 at 11:31
2 Answers
Reset to default 6Change your placeholder
attribute to a value
attribute eg:
<input value='foo'/>
This will make foo the default content for the input which will be editable when the user clicks in the field.
you can use value attribute for that:
<input placeholder="something" value="something"/>
using jquery in runtime:
$('inp_selector').val($('inp_selector').attr('placeholder'))
本文标签: javascriptHow can I make the placeholder text of an html input field editableStack Overflow
版权声明:本文标题:javascript - How can I make the placeholder text of an html input field editable? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742402063a2468082.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论