HTML Input - already filled in text

2020-02-24 12:14发布

I was wondering, is there a way to put text into an input field? What i've got now is a placeholder, but that's actually an empty inputfield. So that's not what i'm looking for. I'm looking for an (kind of) placeholder that's actually filled in into the input field, so not "background text"

This is with placeholder:

http://i.stack.imgur.com/NWY3y.png

And this is what i want:

http://i.stack.imgur.com/AfGSy.png

Is there any way to do this?

Thanks in advance!

5条回答
Summer. ? 凉城
2楼-- · 2020-02-24 12:32

TO give the prefill value in HTML Side as below:

HTML:

<input type="text" id="abc" value="any value">

JQUERY:

$(document).ready(function ()
 {
  $("#abc").val('any value');
 });
查看更多
成全新的幸福
3楼-- · 2020-02-24 12:44
<input type="text" value="Your value">

Use the value attribute for the pre filled in values.

查看更多
不美不萌又怎样
4楼-- · 2020-02-24 12:49

You seem to look for the input attribute value, "the initial value of the control"?

<input type="text" value="Morlodenhof 7" />

https://developer.mozilla.org/de/docs/Web/HTML/Element/Input#attr-value

查看更多
疯言疯语
5楼-- · 2020-02-24 12:49

All you have to do is use the value attribute of input tags:

<input type="text" value="Your Value" />

Or, in the case of a textarea:

<textarea>Your Value</textarea>
查看更多
Lonely孤独者°
6楼-- · 2020-02-24 12:52

The value content attribute gives the default value of the input element.

- http://www.w3.org/TR/html5/forms.html#attr-input-value

To set the default value of an input element, use the value attribute.

<input type="text" value="default value">
查看更多
登录 后发表回答