本文摘自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对象是input还是select
如何解决jQuery参数乱码问题
jQuery 怎么下载
jQuery load方法加载文档时的中文乱码怎么办
在jQuery中如何打开新的窗口
jQuery判断是否包含指定字符串
jQuery有哪些函数
html如何设置input不可编辑
jQuery日期控件怎么用
jQuery如何增加标签属性
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jQuery如何判断input是否被禁用