使用Jquery禁用input的方法:1.新建html项目,引入jquery;2.创建input输入框,设置id属性;3.添加button按钮,绑定onclick点击事件;4.通过id获取input对象,使用attr()方法添加disabl
使用Jquery禁用input的方法:1.新建html项目,引入jquery;2.创建input输入框,设置id属性;3.添加button按钮,绑定onclick点击事件;4.通过id获取input对象,使用attr()方法添加disabled样式,设置disabled实现禁用;
具体步骤如下:
首先,新建一个html项目,并在项目中引入jquery;
<script type="text/javascript" src="/static/jquery-2.1.4.min.js"></script>
引入jquery后,在项目中创建一个input输入框,并设置id属性,用于测试;
<input type="text" value="" id="btn" />
input输入框创建好后,添加一个button按钮,并绑定onclick点击事件,用于点击禁用;
<button onClick="set()"><button>
最后,按钮添加好后,在点击事件中通过id获取input对象,在使用attr()方法为input添加一个disabled样式,并设置为disabled属性,即可实现禁用input;
function set(){
$("#btn").attr("disabled":"disabled");
}
--结束END--
本文标题: jquery如何禁用input
本文链接: https://www.lsjlt.com/news/110211.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0