首页 > 解决方案 > 键入时保留输入的占位符文本

问题描述

我有这个输入:

  <input type="number" class="textfield numberField font"  name="Price" placeholder="Price"><br>

所以文字place holder价格。当用户开始输入时,我想保留这个词price

因此,如果他键入65,他将在输入中看到:

Price 65

我需要在里面为这个词创建另一个 div price,还是可以使用 js 或 html 来完成?

标签: javascripthtml

解决方案


我想你想成为那样的人。

  
.full-input {
  display: inline-block;
  padding: 3px;
  border: 2px solid blue;
}
input {
  outline: none;
  border: none;
  display: inline-block;
  line-height: 1.2em;
  font-size: 14pt;
}
label {
  display: inline-block;
  font-size: 12px;
  color: blue;
}
<div class='full-input'><label for='price'>Price</label>
  <input type='number'class="textfield numberField font"  name="Price">
 </div>


推荐阅读