本文摘自PHP中文网,作者coldplay.xixi,侵删。
jQuery判断input是否被禁用的方法:1、使用函数【is(":disabled")】判断;2、使用函数【prop("disabled")】判断;3、使用函数【attr("disabled")】判断。

本教程操作环境:windows10系统、jquery2.2.4,本文适用于所有品牌的电脑。
推荐:《jquery视频教程》
jQuery判断input是否被禁用的方法:
判断input是否被禁用,可用的方法有:
● is(":disabled")
● prop("disabled")
● attr("disabled")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <script src= "jquery.min.js" ></script>
<br/><input type= "text" id= "first" disabled>first
<br/><input type= "text" id= "second" disabled <br/><input type= "text" id= "third" >third
<script>
var v1, v2, v3;
v1 = $( "#first" ).is( ":disabled" );
v2 = $( "#first" ).prop( "disabled" );
v3 = $( "#first" ).attr( "disabled" );
console.log(v1);
console.log(v2);
console.log(v3);
v1 = $( "#second" ).is( ":disabled" );
v2 = $( "#second" ).prop( "disabled" );
v3 = $( "#second" ).attr( "disabled" );
console.log(v1);
console.log(v2);
console.log(v3);
v1 = $( "#third" ).is( ":disabled" );
v2 = $( "#third" ).prop( "disabled" );
v3 = $( "#third" ).attr( "disabled" );
console.log(v1);
console.log(v2);
console.log(v3);
</script>
|
页面结果:
阅读剩余部分
相关阅读 >>
vue脚手架如何导入jQuery第三方插件
追加的html代码使用jQuery的click事件无效
jQuery中如何实现toggle方法
jQuery怎么删除css样式
jQuery如何判断是否存在class
jQuery的easyui和layui区别是什么
jQuery中怎么跳转页面
jQuery怎么样判断元素是否隐藏起来
jQuery怎样才能判断元素是否绑定事件
jQuery如何判断是否是ie浏览器
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jQuery如何判断input是否被禁用