html - 如何添加带有多个占位符的向下滑动搜索框?
问题描述
我正在研究搜索框和select
元素的混合体。我遇到的问题是,每次我从向下滑动栏中选择一个选项时,我都会在搜索框中看到一个文本。我希望文本成为框内的占位符,而不是普通文本。我不确定该怎么做,所以任何帮助将不胜感激!
测试.html:
<div style="position:relative;width:200px;height:25px;border:0;padding:0;margin:0;">
<select style="position:absolute;top:0px;left:0px;width:200px; height:25px;line-height:20px;margin:0;padding:0;"
onchange="document.getElementById('displayValue').value=this.options[this.selectedIndex].text; document.getElementById('idValue').value=this.options[this.selectedIndex].value;">
<option value="ID">Select ID</option>
<option value="Name">Select Name</option>
<option value="Surname">Select Surname</option>
</select>
<input type="text" name="displayValue" id="displayValue"
placeholder="add/select a value" onfocus="this.select()"
style="position:absolute;top:0px;left:0px;width:183px;width:180px\9;#width:180px;height:23px; height:21px\9;#height:18px;border:1px solid #556;" >
<input name="idValue" id="idValue" type="hidden">
</div>
解决方案
您可以像设置值一样设置占位符:
document.getElementById("displayValue").placeholder = 'New placeholder'
推荐阅读
- java - 无法传递 ArrayList
使用 arg 类型 ArrayList 的方法 - docker - 未在 docker 容器内创建环境变量
- scala - 解析时关闭ResultSet后不允许操作
- performance - 在同一主机上运行多个 jmeter-server
- mariadb - 输出文件连接的 MariaDB SQL 语法错误
- silverstripe - Silverstripe 管理界面可以有分步功能吗?
- python - 迭代删除熊猫数据框行
- python - 来自 Flask Docker 容器的 MongoDB Docker 容器上的连接被拒绝
- sql - 在每个逗号分隔后将数字字符串列拆分为多列
- vb.net - 无法访问 Cursor.Current.Position(访问共享成员....通过实例;将不评估限定表达式