JQuery判断input是否被禁用
<script src="jquery.min.js"></script>
<br/><input type="text" id="first" disabled> first
<br/><input type="text" id="second" disabled="disabled"> second
<br/><input type="text" id="third"> third
<script>
var v1, v2, v3;
v1 = $("#first").is(":disabled"); // true / false
v2 = $("#first").prop("disabled"); // true / false
v3 = $("#first").attr("disabled"); // disabled / undefined
console.log(v1);
console.log(v2);
console.log(v3);
v1 = $("#second").is(":disabled"); // true / false
v2 = $("#second").prop("disabled"); // true / false
v3 = $("#second").attr("disabled"); // disabled / undefined
console.log(v1);
console.log(v2);
console.log(v3);
v1 = $("#third").is(":disabled"); // true / false
v2 = $("#third").prop("disabled"); // true / false
v3 = $("#third").attr("disabled"); // disabled / undefined
console.log(v1);
console.log(v2);
console.log(v3);
</script>
页面结果:

控制台输出:

使用prop设置禁用与解除禁用:
$("#first").prop("disabled",true); //禁用
$("#first").prop("disabled",false); //可编辑
$("#first").prop("disabled",“disabled”);//禁用
$("#first").prop("disabled",“”); //可编辑
使用attribute设置禁用与解除禁用:
$("#first").attr("disabled",true); //禁用
$("#first").attr("disabled",false); //可编辑
$("#first").attr("disabled","disabled");//禁用
$("#first").attr("disabled",""); //禁用
$("#first").removeAttr("disabled"); //可编辑
JQuery判断input是否被禁用的更多相关文章
- jquery判断 input type="file"上传文件是否为空
要想获取type="file"的input内容,用var file = $("id").val();肯定是不行的,下面是代码: html上传按钮为: <i ...
- jquery判断input值不为空 val()
<input type="text" class="searchbox" /> <script type='text/javascript'& ...
- jquery判断input选中事件
需求是默认第一个是选中状态,点第二个选中,第一个取消然后点支付时,跳转新页面 $(function(){ $(".nl_zhifutj a").click(function(){ ...
- jQuery如何判断input元素是否获得焦点(点击编辑时)
问题提出 如果你要判断input元素是否获得焦点,或者是否处在活动编辑状态,使用jQuery的 hasFocus() 方法或 is(':focus') 方法貌似都无效!搜索网上给出的办法,几乎净是采用 ...
- 基于MVC4+EasyUI的Web开发框架经验总结(1)-利用jQuery Tags Input 插件显示选择记录
最近花了不少时间在重构和进一步提炼我的Web开发框架上,力求在用户体验和界面设计方面,和Winform开发框架保持一致,而在Web上,我主要采用EasyUI的前端界面处理技术,走MVC的技术路线,在重 ...
- 基于jQuery的input输入框下拉提示层(自动邮箱后缀名)
基于jQuery的input输入框下拉提示层,方便用户输入邮箱时的提示信息,需要的朋友可以参考下 效果图 // JavaScript Document (function($){ $.fn ...
- JQuery判断radio是否选中,获取选中值
本文摘自:http://www.cnblogs.com/xcj1989/archive/2011/06/29/JQUERY_RADIO.html /*----------------------- ...
- JQuery 判断某个属性是否存在 hasAttr
$(".fengye a").each(function () { if (typeof($(this).attr("href")) != "unde ...
- JQuery控制input的readonly和disabled属性
jquery设置元素的readonly和disabled Jquery的api中提供了对元素应用disabled和readonly属性的方法,在这里记录下.如下: 1.readonly $('in ...
随机推荐
- js备忘录_1
js没有重载,只有同名覆盖,参数任意 所有参数封装在arguments数组中 Uncaught ReferenceError: d is not defined js引擎会当做变量处理 functio ...
- CH0103最短Hamilton路径 & poj2288 Islands and Brigdes【状压DP】
虐狗宝典学习笔记: 取出整数\(n\)在二进制表示下的第\(k\)位 \((n >> ...
- VUE中父组件向子组件传递数据 props使用
VUE中,子组件是不能直接访问父组件的数据(一般来说,当然如果你要破坏原则也是可以),如下< <body> <div id="fathercomponent" ...
- CodeForces - 617E XOR and Favorite Number 莫队算法
https://vjudge.net/problem/CodeForces-617E 题意,给你n个数ax,m个询问Ly,Ry, 问LR内有几对i,j,使得ai^...^ aj =k. 题解:第一道 ...
- ubuntu/debian ia-libs
ubuntu 14.04强制安装ia32-libs 1.切换到root权限sudo -i 或 sudo su2.进入apt源列表cd /etc/apt/sources.list.d3.添加ubuntu ...
- related Field has invalid lookup: icontains 解决方法
models.py 文件 # coding:utf8 from django.db import models class Book(models.Model): name = mod ...
- (3.3)mysql基础深入——mysql启动深入分析
基础:(2.1)学习笔记之mysql基本操作(启动与关闭) 0.mysql启动的 3种方式 (1)mysql.server (2)mysqld_safe (3)mysqld 1.启动分析 [1.1]概 ...
- [sh]sh最佳实战(含grep)
sh虐我千百遍,我待sh如初恋. sh复习资料 http://www.cnblogs.com/iiiiher/p/5385108.html http://blog.csdn.net/iiiiher/a ...
- [LeetCode] 694. Number of Distinct Islands
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- [LeetCode] 675. Cut Off Trees for Golf Event_Hard tag: BFS
You are asked to cut off trees in a forest for a golf event. The forest is represented as a non-nega ...