本文摘自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>
|
页面结果:
阅读剩余部分
相关阅读 >>
jQuery对象怎么转为html dom对象
谷歌浏览的label与input间距问题应该如何解决
jQuery如何判断元素中是否存在标签
jQuery符号===和==区别是什么
jQuery基本过滤器有哪些
如何删除css样式
jQuery $.post方法不执行怎么办
无法引用 jQuery怎么办
jQuery中deferred对象是什么?
jQuery如何获取鼠标位置
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jQuery如何判断input是否被禁用