select默认为空,下拉选项中option不为空
2018-01-09 14:16
447 查看
网上找了几个方法不行,终于找到一篇博客,解决了,里面有三个方法,用了一个最简单的。
在option 添加 style='display: none'
另外两种:
1、<option selected="selected" disabled="disabled" style='display: none' value=''></option>
2、
html:
<body onload="load()">
<select id="abc" >
<option >1</option>
<option >2</option>
<option >3</option>
<option >4</option>
</select>
</body>
js:
<script>
function load()
{
var x = document.getElementById("abc");
x.selectedIndex = -1;
}
</script>
原文博客地址 :
原文地址
在option 添加 style='display: none'
另外两种:
1、<option selected="selected" disabled="disabled" style='display: none' value=''></option>
2、
html:
<body onload="load()">
<select id="abc" >
<option >1</option>
<option >2</option>
<option >3</option>
<option >4</option>
</select>
</body>
js:
<script>
function load()
{
var x = document.getElementById("abc");
x.selectedIndex = -1;
}
</script>
原文博客地址 :
原文地址
相关文章推荐
- select动态添加option与动态设置下拉框默认选项(selected)的问题(原创)
- 怎样把select中的option禁止了-也就是怎么禁止选择下拉框中的某个选项
- select默认下拉箭头改变、option样式清除
- 关于Select option默认选中及查询后选项值保留的问题
- 动态给select下拉列表添加选项option
- select下拉列表, 从数据库查询,动态添加选项option
- jQuery设置下拉框select 默认选中第一个option
- 关于Select option默认选中及查询后选项值保留的问题
- html的select标签怎么让其显示一默认option选项
- select默认下拉箭头改变、option样式清除
- bootstrap-select动态组装下拉选项(option)
- Jquery获得select下拉选项option的值:
- select默认文字,不出现在下拉选项中
- 删除下拉列表选项 删除select中的option
- 将select下拉框中的非默认选项均置灰
- jQuery设置下拉框select 默认选中option
- 正则匹配:去除字符串中的空格,获取select下拉选项中的option的文本内容
- select默认选择后台转过来的option选项
- 怎样把select中的option禁止了-也就是怎么禁止选择下拉框中的某个选项
- jQuery设置下拉框select 默认选中第一个option