jquery设置表单元素为不可用的简单代码


本章节通过简单的实例代码介绍一下如何将表单元素设置为不可用状态。

代码实例如下:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset=" utf-8"> 
<meta name="author" content="http://www.phpstudy.net/" /> 
<title>phpstudy</title> 
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script> 
<script type="text/javascript"> 
$(function(){ 
 $("#webname").prop("disabled","disabled"); 
 $("#bt").prop("disabled","disabled"); 
}) 
</script> 
</head> 
<body> 
网站名称:<input type="text" id="webname"/><br/> 
phpstudy<input type="button" value="查看效果" id="bt"/> 
</body> 
</html>

以上代码通过prop()函数设置表单元素的disabled属性即可。

以上这篇jquery设置表单元素为不可用的简单代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持phpstudy。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3