html里select怎么设置和取消disabled
2016-09-13 11:23
399 查看
很多人都认为设置disabled="true"是为启用,设置为“false”时为禁用,这是错的。只要元素里面设置了disabled=“xxx”不管"xxx"是什么都为禁用。 //两种方法设置disabled属性 $('#areaSelect').attr("disabled",true); $('#areaSelect').attr("disabled","disabled"); //三种方法移除disabled属性 $('#areaSelect').attr("disabled",false); $('#areaSelect').removeAttr("disabled"); $('#areaSelect').attr("disabled","");
<html> <head> <script type="text/javascript"> function disable() { [code]document.getElementById("mySelect").disabled=true
}
function enable()
{
document.getElementById("mySelect").disabled=false
}
</script>
</head>
<body>
<form>
<select id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
<br /><br />
<input type="button" onclick="disable()" value="Disable list">
<input type="button" onclick="enable()" value="Enable list">
</form>
</body>
</html>[/code]
相关文章推荐
- HTML块级元素和行级元素
- HTML元素居中显示的方法
- Html的一些有意思的标签
- 隐藏项目中的HTML控件方法
- html运用(五) readonly 和 disable的区别
- html中去掉input获取焦点时候的边框
- HTML属性及方法
- html布局之 图标文字混排
- HTML编码规范
- Easy way to use JText 2.1.7 and HTML-style template for generating report
- Html登录弹出框的实现
- innerText和innerHtml的区别
- 错误信息:响应消息的内容类型 text/html; charset=utf-8 与绑定(text/xml; charset=utf-8)的内 容类型不匹配
- html运用(四) html解决浏览器记住密码输入框的问题
- HTML中的几种定位方式
- html运用(三) html如何禁止(表单)用户名、密码自动填充
- HTML DOM常用的操作
- 【转】百度首页html练习
- HTML实现跳转到页面指定位置
- html 定位问题