jQuery设置元素attribute之特殊属性
一般我们使用.attr()对某个dom元素设置attribute属性。今天在使用过程中发现在给input设置disabled属性为true时,最终元素disabled属性值解析成了disabled,并不是所需要的true。
查看jQuery的源码后才发现,jQuery内置有个属性集合,当要设置的属性在这个集合里面的时候,值就统一设置为该属性。
这个集合的名称为jQuery.expr.match.bool。对应的正则表达式值如下
/^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i
刚开始没有去看源码的时候,还以为是HTML的机制呢,个人觉得jQuery这样做的原因应该是为了符合html的规范吧。
jQuery设置元素attribute之特殊属性的更多相关文章
- jquery设置元素的readonly和disabled
jquery设置元素的readonly和disabled Jquery的api中提供了对元素应用disabled和readonly属性的方法,在这里记录下.如下: $( '#line2Tr' ).cs ...
- [Web 前端] Jquery 复制元素,并修改属性, 追加到另一个元素后面
cp from : https://blog.csdn.net/cooledi/article/details/52813668 jquery 复制元素,并修改属性 $('#ID').clone() ...
- jquery设置元素的readonly与diabled属性方法
cppy from : http://www.cnblogs.com/RascallySnake/archive/2010/08/03/1791365.html Jquery的api中提供了对元素应用 ...
- jQuery设置元素的readonly和disabled属性
jQuery的api中提供了对元素应用disabled和readonly属性的方法,如下: 1.readonly $('input').attr("readonly",&qu ...
- jquery设置元素readonly和disabled(checkbox只读)
jquery api中提供了对元素应用disabled和readonly属性的方法:1,readonly 代码示例: $('input').attr("readonly",&quo ...
- jquery设置元素的readonly和disabled【转】
Jquery的api中提供了对元素应用disabled和readonly属性的方法,在这里记录下.如下: 1.readonly $('input').attr("readonly&qu ...
- jquery 设置元素内容html(),text(),val()
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 从零开始学习jQuery (四) 使用jQuery操作元素的属性与样式
本系列文章导航 从零开始学习jQuery (四) 使用jQuery操作元素的属性与样式 一.摘要 本篇文章讲解如何使用jQuery获取和操作元素的属性和CSS样式. 其中DOM属性和元素属性的区分值得 ...
- jQuery入门(2)使用jQuery操作元素的属性与样式
jQuery入门(1)jQuery中万能的选择器 jQuery入门(2)使用jQuery操作元素的属性与样式 jQuery入门(3)事件与事件对象 jQuery入门(4)jQuery中的Ajax()应 ...
随机推荐
- JS实现页面加载完毕之前loading提示效果
1.获取浏览器页面可见高度和宽度 var _PageHeight = document.documentElement.clientHeight, _PageWidth = document.docu ...
- 适配iOS10 的相关权限设置
解决办法(fix method):在info.plist —Source Code中添加UsageDescription相关的key, 描述字符串自己随意填写就可以,但是一定要填写,不然会引发包无效的 ...
- (1)WCF少废话系列之 _Hello WCF!
本节旨在通过实例的方式让初学者对WCF有一个感性的认识,坚持由特殊到普遍再由普遍到特殊的认知规律. WCF(Windows Communication Fundation),微软分布式通信架构的集合, ...
- 使用CSDN Code将网站部署到Windows Azure Website上
在云计算时代,开发和部署应该是完全统一和集成的.在海外,开发者可以用github来管理他们的代码,并且直接部署到Windows Azure上.随着Windows Azure在国内的发布,我们发现,其实 ...
- Oracle数据库如何创建DATABASE LINK?
Oracle数据库如何创建DATABASE LINK? 2011-08-09 14:54 taowei20061122 CSDN博客 http://blog.csdn.net/taowei20061 ...
- C++中常见错误整理(不定期更新)
1.cannot have cv-qualifier 在C++中CV指const和volatile,非成员函数和静态成员函数不能有CV限定.
- JAVAFX纯手写布局
主页面效果: 第一栏的效果: 工程目录: package MessageBean; /** * * @author novo */ public class Message { private Str ...
- JS 日期格式化
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"& ...
- java之并发编程:Lock
这是转的:http://www.cnblogs.com/dolphin0520/p/3923167.html * 在多线程编程里面一个重要的概念是锁定,如果一个资源是多个线程共享的,为了保证数据的完整 ...
- android之fragment
觉得写得好:http://blog.csdn.net/shulianghan/article/details/38064191