首页 咨询中心 IT学堂
通过jquery的attr()函数设置按钮的disable属性使按钮禁用或者启用

在写网页程序时可以通过jquery中的attr()函数修改设置按钮等表单控件的disable属性 让按钮禁用或者让按钮从禁用改为启用,
$(’#button’).attr(’disabled’,"true");添加disabled属性  
$(’#button’).removeattr("disabled"); 移除disabled属性 

在html标签中设置按钮被禁用,可以使用如下代码 
<input type=’button’ id=’test’ value=’disabled’> 
在jquery中可以使用attr()函数修改按钮的disable属性 
$(“#test”).attr(‘disabled’,false); 


看一款完整实例代码 

<!doctype html> 
<html> 
<head> 
  <script src="http://code.jquery.com/jquery-1.4.4.js"></script> 
</head> 
<body> 
  <form action="index.asp"> 

    <input name="email" disabled="disabled" /> 
    <input name="id" /> 
     
     
    <input name="修改按钮的disable属性" type=’submit’ id=’test’ value="修改按钮的disable属性"    > 
在jquery中可以使用attr()函数修改按钮的disable属性 


  </form> 
<script>$("input:disabled").val("this is it"); 
$("input:disabled").attr(’disabled’,true); 
$("#test").attr(’disabled’,true); 


</script> 

</body> 
</html>

上海专业网页设计公司上联网络原为你企业信息化帮你精心设计你公司的网页http://www.web258.cn

上一篇 asp不等于无郊时请注意是不是你的数据类型不一样
上一篇 360浏览器器在线编辑器无法用不正常或者不能粘贴可通过下面方法解决
本方链接: http://www.web258.cn/article/show/i1326.html
ARTICLE 相关推荐