javascript - 与静态内容重叠的输入标签

标签 javascript jquery html css

我在 html 中有两个重叠的输入标签。我希望其中一个应该有 $ 符号,而另一个应该有 Value 作为占位符。现在,当它们重叠时,我希望当用户按下 tab 键并到达重叠的输入框时,它应该选择 Value 作为占位符的输入框。通过这个我想实现 $ sin 应该是静态的。

<div id="twoinput" style="width: 40%; float: right;">                    
    <input id="visiblevalue" type="text" name="value" placeholder="$ Value" value="" required="required" onfocus="if(this.value == '') this.value='$ '" onblur="if(this.value == '$ ') this.value = ''" onkeydown="return isNumber(event);"  />
    <input id=hiddenvalue type="text" placeholder="Value" value="" required="required" onfocus="this.placeholder=''" onblur="if(this.value=='')this.placeholder='Value'" />
</div>
#twoinput{
    position:relative;
}
#visiblevalue{
    position:absolute;
}
#hiddenvalue{
    bottom: 0; 
    right:0;
    left:0;
}
#twoinput{
    position:relative;
}
#visiblevalue{
    position:absolute;
}
#hiddenvalue{
    bottom: 0; 
    right:0;
    left:0;
}

最佳答案

没有必要使用输入标签来保持 $ 符号。使用 Bootstrap 将 $ 添加到输入框:

这是一个用法示例:

<div class="input-group">
  <span class="input-group-addon">$</span>
  <input type="text" class="form-control">
</div>

这是 Bootstrap 文档的链接: http://getbootstrap.com/components/#input-groups

关于javascript - 与静态内容重叠的输入标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25346727/

相关文章:

javascript - 尝试使用 jquery 使图像旋转

javascript - "Uncaught TypeError: history.push is not a function"发生错误

javascript - jquery动态添加html字段遇到神秘问题

javascript - 调整 Owl Carousel 的高度

html - 使图像和列表出现在同一行

javascript - 我的机器人从本地目录中提取图像,如何将其更改为网络上托管的文件夹?

javascript - react 计算器 : limiting number of inputs

javascript - 数据表,在其中为单个行格式编写自定义 HTML 代码

javascript - 为所有子项添加事件监听器

PHP行删除