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参数的更多相关文章

  1. vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示

    vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示 https://cn.vuejs.org/v2/guide/class-and-sty ...

  2. jmeter压测学习3-提取json数据里面的token参数关联

    前言 现在很多接口的登录是返回一个json数据,token值在返回的json里面,在jmeter里面也可以直接提取json里面的值. 上一个接口返回的token作为下个接口的入参. 案例场景 我现在有 ...

  3. 关于Nginx里面的配置文件里面的location参数的意思

    location是指当遇到这个单词的时候,把root改成大括号里面的值,再把单词和后面的路径加上root变成总的文件路径进行搜索,如果没有location,直接把root加上域名后面的路径变成总的文件 ...

  4. 微信小程序--修改data数组或对象里面的值

    1.初始data数据 Page({     data:{          code:'1234',         reward:[{             name:"艾伦" ...

  5. spring里面的context:component-scan

    原文:http://jinnianshilongnian.iteye.com/blog/1762632 component-scan的作用的自动扫描,把扫描到加了注解Java文件都注册成bean &l ...

  6. 控制台打印出event对象时,对象里面的currentTarget为null

    但是MouseEvent对象展开时 附上老外的解释~~~: http://stackoverflow.com/questions/26496176/when-loggin-an-event-objec ...

  7. EF修改对象里面的值。。。(对象字段多的时候)

    后台代码 public ActionResult Edit(my m)//my实体类 { testEntities t = new testEntities();//数据库上下文 t.my.Attac ...

  8. jQuery源代码学习笔记:jQuery.fn.init(selector,context,rootjQuery)代码具体解释

    3.1 源代码 init: function( selector, context, rootjQuery ) { var match, elem, ret, doc; // Handle $(&qu ...

  9. JQuery日记 5.31 JQuery对象的生成

    JQuery对象的生成 1 selector为不论什么可转换false的空值   返回空JQuery对象 2 selector为字符串   2.1 selector为html字符串或有id属性的标签 ...

随机推荐

  1. 【leetcode刷题笔记】Construct Binary Tree from Preorder and Inorder Traversal

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  2. 使用WindowsAPI实现播放PCM音频的方法

    这篇文章主要介绍了使用WindowsAPI实现播放PCM音频的方法,很实用的一个功能,需要的朋友可以参考下 本文介绍了使用WindowsAPI实现播放PCM音频的方法,同前面一篇使用WindowsAP ...

  3. hdu 4372 Count the Buildings —— 思路+第一类斯特林数

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4372 首先,最高的会被看见: 然后考虑剩下 \( x+y-2 \) 个被看见的,每个带了一群被它挡住的楼, ...

  4. 三 volatile关键字

    一:内存模型: 大家都知道,计算机在执行程序时,每条指令都是在CPU中执行的,而执行指令过程中,势必涉及到数据的读取和写入.由于程序运行过程中的临时数据是存放在主存(物理内存)当中的,这时就存在一个问 ...

  5. java类加载器-----用户自定义类加载器实现

    java类加载器主要分为如下几种: jvm提供的类加载器 根类加载器:底层实现,主要加载java核心类库(如:java.lang.*) 扩展类加载器:使用java代码实现,主要加载如:jre/lib/ ...

  6. 使用SecureCRT工具部署项目

    总结下我的Java开发过程的一些知识点: 我要上线某个项目,此时我需要给测试人员发送安全扫描文件,等待测试人员完成项目的扫描之后才可以完成上线: 1 将项目打成war包.比如implgtyy.war文 ...

  7. Servlet的一些细节

    由于客户端是通过URL地址访问web服务器的中的资源的,所以Servlet程序若想被外界访问,必须把servlet程序映射到一个URL地址上,这个工作在web.xml文件中使用<servlet& ...

  8. Spring入门第六课

    XML配置里的Bean自动装配 Spring IOC容器可以自动装配Bean.需要做的仅仅是在<bean>的autowire属性里指定自动装配的模式 ByType(根据类型自动装配):若I ...

  9. The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object

    The project was not built since its build path is incomplete. Cannot find the class file for java.la ...

  10. android开源项目:图片下载缓存库picasso

    picasso是Square公司开源的一个Android图形缓存库,地址http://square.github.io/picasso/,可以实现图片下载和缓存功能. picasso有如下特性: 在a ...