jquery对象里面的context参数
jquery源码:
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
// Need init if jQuery is called (just allow error to be thrown if not included)
return new jQuery.fn.init( selector, context );
},
对于这个context的解释是这样的:
他可以控制前面selector的范围,context既可以是jquery对象,也可以是DOM对象,不过区别是,jquery对象的context依然为document,而DOM对象的context为你选择的DOM对象。
如图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>conText</title>
</head>
<body>
<div>
<ul class="cc">
<li class="aa"></li>
<li class="bb"></li>
<li class="aa"></li>
<li class="aa"></li>
<li class="aa"></li>
</ul>
<ul class="dd">
<li class="aa"></li>
<li class="bb"></li>
<li class="aa"></li>
<li class="ff"></li>
<li class="aa"></li>
</ul>
</div>
<script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$('.bb',$('.dd')).css('background','red')
var dd = document.getElementsByClassName('dd');
console.log($('.bb',$('.dd')));
console.log($('.bb',dd[0]));
</script>
</body>
</html>

jquery对象里面的context参数的更多相关文章
- vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示
vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示 https://cn.vuejs.org/v2/guide/class-and-sty ...
- jmeter压测学习3-提取json数据里面的token参数关联
前言 现在很多接口的登录是返回一个json数据,token值在返回的json里面,在jmeter里面也可以直接提取json里面的值. 上一个接口返回的token作为下个接口的入参. 案例场景 我现在有 ...
- 关于Nginx里面的配置文件里面的location参数的意思
location是指当遇到这个单词的时候,把root改成大括号里面的值,再把单词和后面的路径加上root变成总的文件路径进行搜索,如果没有location,直接把root加上域名后面的路径变成总的文件 ...
- 微信小程序--修改data数组或对象里面的值
1.初始data数据 Page({ data:{ code:'1234', reward:[{ name:"艾伦" ...
- spring里面的context:component-scan
原文:http://jinnianshilongnian.iteye.com/blog/1762632 component-scan的作用的自动扫描,把扫描到加了注解Java文件都注册成bean &l ...
- 控制台打印出event对象时,对象里面的currentTarget为null
但是MouseEvent对象展开时 附上老外的解释~~~: http://stackoverflow.com/questions/26496176/when-loggin-an-event-objec ...
- EF修改对象里面的值。。。(对象字段多的时候)
后台代码 public ActionResult Edit(my m)//my实体类 { testEntities t = new testEntities();//数据库上下文 t.my.Attac ...
- jQuery源代码学习笔记:jQuery.fn.init(selector,context,rootjQuery)代码具体解释
3.1 源代码 init: function( selector, context, rootjQuery ) { var match, elem, ret, doc; // Handle $(&qu ...
- JQuery日记 5.31 JQuery对象的生成
JQuery对象的生成 1 selector为不论什么可转换false的空值 返回空JQuery对象 2 selector为字符串 2.1 selector为html字符串或有id属性的标签 ...
随机推荐
- 文件系统(node.js学习笔记)
根据nodejs菜鸟教程整理. 官方API文档:nodeJS文件系统API 其他整理:nodejs File System 文件系统操作函数分类 1.引用: 导入文件系统模块(fs)语句:var fs ...
- ACM学习历程—HDU 5072 Coprime(容斥原理)
Description There are n people standing in a line. Each of them has a unique id number. Now the Ragn ...
- bzoj 4537: [Hnoi2016]最小公倍数 分块+并查集
题目大意: 给定一张n个点m条边的无向图,每条边有两种权.每次询问某两个点之间是否存在一条路径上的边的两种权的最大值分别等于给定值. n,q <= 50000. m <= 100000 题 ...
- docker 局域网仓库(registry)
sudo docker pull daocloud.io/registry 安装仓库(registry) 使用daocloud/aliyun镜像吧,官网仓库真心没法用 sudo docker r ...
- 洛谷 P4547 & bzoj 5006 随机二分图 —— 状压DP+期望
题目:https://www.luogu.org/problemnew/show/P4547 https://www.lydsy.com/JudgeOnline/problem.php?id=5006 ...
- c++11中用_sntprintf代替_stprintf
sprintf.swprintf 分别是对单字节/双字节字符格式化的,wsprintf根据预定义指示符的不同可以对单字节/双字节字符格式化. wsprintf和swprintf比较,其实这两个函数对用 ...
- mysql查询语句例题
1.一条SQL语句查询两表中两个字段 首先描述问题,student表中有字段startID,endID.garde表中的ID需要对应student表中的startID或者student表中的endID ...
- JasperReports项目中的应用
转自:http://www.blogjava.net/vjame/archive/2013/10/12/404908.html . 2.业务处理 //返回报表查询结果 List<ReportEl ...
- NET项目中分页方法
/// <summary> /// 获得查询分页数据 /// </summary> public DataSet GetList(int pageSize, int pageI ...
- C#调用ODBC连接SQL Server数据库的存储过程
OdbcConnection con = new OdbcConnection("Driver={SQL Server};server=PC-200201070359;uid=sa;pwd= ...