jquery设置表单元素为不可用的简单代码
时间:2021-09-19 07:53:51|栏目:jquery|点击: 次
本章节通过简单的实例代码介绍一下如何将表单元素设置为不可用状态。
代码实例如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="https://www.jb51.net/" />
<title>脚本之家</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/>
脚本之家<input type="button" value="查看效果" id="bt"/>
</body>
</html>
以上代码通过prop()函数设置表单元素的disabled属性即可。






