javascript - How can I make the placeholder text of an html input field editable? - Stack Overflow

I have something like this<input placeholder="something">The default behavior is the p

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
Add a ment  | 

2 Answers 2

Reset to default 6

Change 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'))

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742402063a4437109.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信