Ext.dom.Query


Element Selectors:(元素选择器)

Ext.core.DomQuery.select('表达式')   返回HTMLElement[]

* any element

Ext.core.DomQuery.select('*') //返回所有dom元素

E an element with the tag E

Ext.core.DomQuery.select('div') //返回所有div元素

E F All descendent elements of E that have the tag F

Ext.core.DomQuery.select('div span') //返回所有div下的span元素 (无限层级 1,2都会匹配)

      <div>
<span>1</span>
<p>
<span>2</span>
</p>
</div>

E > F or E/F all direct children elements of E that have the tag F1 

Ext.DomQuery.select("div > span") //匹配直接子元素 只向下查询一级(返回1)

      <div>
<span>1</span>
<p>
<span>2</span>
</p>
</div>

E + F all elements with the tag F that are immediately preceded by an element with the tag E

Ext.DomQuery.select("div + span") //返回平级的 下面第一个匹配的元素 (444)

E ~ F all elements with the tag F that are preceded by a sibling element with the tag E

Ext.DomQuery.select("div ~ span") //返回平级的 下面所有匹配的元素 (444,666,777,888) 注意不匹配555,只返回平级的

      <span id="111"></span>
<div>
<span id="222"></span>
<h1></h1>
<span id="333"></span>
</div>
<span id="444"><span id="555"></span></span>
<span id="666"></span>
<span id="777"></span>
<span id="888"></span>

Attribute Selectors:(属性选择器)

E[foo] has an attribute "foo"

Ext.DomQuery.select('*[foo]') //返回包含foo属性的所有元素(*代表所有DOM元素)

Ext.DomQuery.select('div[foo]') //返回包含foo属性的所有DIV元素

E[foo=bar] has an attribute "foo" that equals "bar"

Ext.DomQuery.select('div[foo=bar]') //返回所有属性foo等于bar的DIV元素

E[foo^=bar] has an attribute "foo" that starts with "bar"

Ext.DomQuery.select('div[foo^=bar]') //返回所有属性foo已bar开头的DIV元素

E[foo$=bar] has an attribute "foo" that ends with "bar"

Ext.DomQuery.select('div[foo$=bar]') //返回所有属性foo已bar结尾的DIV元素

E[foo*=bar] has an attribute "foo" that contains the substring "bar"

Ext.DomQuery.select('div[foo*=bar]') //返回所有属性foo包含bar的DIV元素

E[foo%=2] has an attribute "foo" that is evenly divisible by 2

Ext.DomQuery.select('div[foo%=bar]') //返回所有属性foo能被2整除的DIV元素

E[foo!=bar] attribute "foo" does not equal "bar"

Ext.DomQuery.select('div[foo%=bar]') //返回所有属性foo不等于bar的DIV元素


CSS Value Selectors:(Css选择器)

与属性上面的属性选择器用法一样,只不过这里匹配的是CSS,STYLE

        .mydiv {
display: none;
}
<div style="width: 300; display: none;" >22</div>
<div class="myidv"></div>

E{display=none} css value "display" that equals "none"

E{display^=none} css value "display" that starts with "none"

E{display$=none} css value "display" that ends with "none"

E{display*=none} css value "display" that contains the substring "none"

E{display%=2} css value "display" that is evenly divisible by 2

E{display!=none} css value "display" that does not equal "none"


Pseudo Classes:(伪类选择器)

E:first-child E is the first child of its parent

Ext.DomQuery.select('div:first-child') //返回元素E ,并且E是它父元素的下面的第一个子元素

//返回div0 , div1 因为div0的父元素是body 并且它是body在面的第一个元素 ,div1的父元素是div0. 并且他是div0下面的第一个元素

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2"></div>
</div>
<span>33</span>
</div>
<div id="3"></div>
</body>

E:last-child E is the last child of its parent

Ext.DomQuery.select('div:last-child') //跟上面的正好相反.是父元素中的最后一个元素

//返回div2,div3

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2"></div>
</div>
<span>33</span>
</div>
<div id="3"></div>
</body>

E:nth-child(_n_) E is the _n_th child of its parent (1 based as per the spec)

//Ext.DomQuery.select('div:nth-child(1)') 返回在其父元素中 第N个的E元素 返回 div0,div1,div4

//Ext.DomQuery.select('div:nth-child(2)')  返回div2,div3

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2"></div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
</body>

E:nth-child(odd) E is an odd child of its parent

//与上面类似 返回奇数

E:nth-child(even) E is an even child of its parent

//与上面类似 返回偶数

E:only-child E is the only child of its parent

//Ext.DomQuery.select('div:only-child') 返回父元素当中只有一个元素的E元素,返回div4

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2"></div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
</body>

E:checked E is an element that is has a checked attribute that is true (e.g. a radio or checkbox)

//Ext.DomQuery.select('input:checked')  返回选中的元素 1,2

      <input id="1" name="hobby" checked="checked" type="checkbox">
<input id="2" name="hobby" checked="checked" type="checkbox">
<input id="3" name="hobby" type="checkbox">

E:first the first E in the resultset

//返回匹配元素结果集中的第一个元素

E:last the last E in the resultset

//返回匹配元素结果集中的最后一个元素

E:nth(_n_) the _n_th E in the resultset (1 based)

//返回匹配元素结果集中的第N个元素

E:odd shortcut for :nth-child(odd)

//与:nth-child(odd)相同

E:even shortcut for :nth-child(even)

//于:nth-child(even)相同

E:contains(foo) E's innerHTML contains the substring "foo"

//Ext.DomQuery.select('div:contains(foo)')  innerHTML 属性中包含foo的E元素, [div#0, div#1, div#2]

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>
</body>

E:nodeValue(foo) E contains a textNode with a nodeValue that equals "foo"

//Ext.DomQuery.select('div:nodeValue(foo)')//返回值包含一个文本元素,并且值为foo的 div元素 [div#2]

      <div id="0">
<div id="1">
foo
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>

E:not(S) an E element that does not match simple selector S

//Ext.DomQuery.select('div:not([id=3])') (注意红色地方放选择器表达式) 返回id 不等于3的div 返回 [div#0, div#1, div#2, div#4, div#5]

      <div id="0">
<div id="1">
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>

E:has(S) an E element that has a descendent that matches simple selector S

//Ext.DomQuery.select('div:has(span[id=s1])')  返回包含span[id=s1]表达式所匹配元素的 div元素

//返回[div#0, div#1]

      <div id="0">
<div id="1">
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>

E:next(S) an E element whose next sibling matches simple selector S

//Ext.DomQuery.select('div:next(div[id=3])') 返回div元素,并且其平级元素的下一个是div[id=3]所匹配的元素

//匹配 div#1

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>
</body>

E:prev(S) an E element whose previous sibling matches simple selector S

//Ext.DomQuery.select('div:next(div[id=3])') 返回div元素,并且其平级元素的上一个是div[id=3]所匹配的元素

//匹配div#5

  <body>
<div id="0">
<div id="1">
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>
</body>

E:any(S1|S2|S2) an E element which matches any of the simple selectors S1, S2 or S3

//Ext.DomQuery.select('div:any([id=2]|[id=3]|[id=4])') 或者的关系

E:visible(true) an E element which is deeply visible according to Ext.dom.Element.isVisible

//Ext.DomQuery.select('div:visible(true)') 匹配所有可见的div 返回 [div#0, div#3, div#4, div#5]

  <body>
<div id="0">
<div id="1" style="display: none;">
<span id="s1"></span>
<div id="2">foo</div>
</div>
<span>33</span>
</div>
<div id="3">
<div id="4"></div>
</div>
<div id="5"></div>
</body>

Ext.core.DomQuery Dom选择器的更多相关文章

  1. ExtJs之Ext.core.DomQuery

    <!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...

  2. ExtJS初接触 —— 了解 Ext Core

    ExtJS初接触 —— 了解 Ext Core Ext Core是一款和jQuery媲美的轻型JS库,基于MIT许可.对于Dom的操作,我个人还是比较喜欢用jQuery.当然如果项目中用的是ExtJS ...

  3. ExtJS初探:了解 Ext Core

    Ext Core是一款和jQuery媲美的轻型JS库,基于MIT许可.对于Dom的操作,我个人还是比较喜欢用jQuery.当然如果项目中用的是ExtJS框架,也就没必要多引用一个jQuery,Ext ...

  4. dom core,html dom,css dom,jquery 中的dom操作

    前端开发中为达到某种目的,往往有很多方法:dom core,html dom,jquery; dom core/jquery主要通过函数调用的方式(getAttribute("属性名&quo ...

  5. 都别说工资低了,我们来一起写简单的dom选择器吧!

    前言 我师父(http://www.cnblogs.com/aaronjs/)说应当阅读框架(jquery),所以老夫就准备开始看了 然后公司的师兄原来写了个dom选择器,感觉不错啊!!!原来自己从来 ...

  6. 关于一个新的DOM选择器querySelector

    在传统的javascript中,提到DOM选择器,大家比较熟悉的方式是通过tag,name,id来获取,其实大家都发现如果获取比较复杂的话,用这个方法会很繁琐,这时大家应该都会想到jquery里获取一 ...

  7. ExtJs之Ext.core.DomHelper.append

    <!DOCTYPE html> <html> <head> <title>ExtJs</title> <meta http-equiv ...

  8. 一周学会Mootools 1.4中文教程:(1)Dom选择器

    利器: 君欲善其事须先利其器,好吧因为我们的时间比较紧迫,只有六天而已,那么六天的时间用死记硬背的方式学会Mt犹如天方夜谭,因此我们需要借鉴一下Editplus的素材栏帮我们记忆就好了,当我们需要用到 ...

  9. DOM选择器

    DOM选择器分为:id.class.name.tagname.高级.关系选择器;(返回的都是标签) 一:元素节点选择器: 1. id: 返回的是单个对象 <body> <div cl ...

随机推荐

  1. oracle客户端服务端字符集-解决乱码

    查询server段字符集 select userenv('language') from dual 查询client段字符集 select * from v$nls_parameters NLS_LA ...

  2. skimage exposure模块解读

    exposure模块包括: 直方图均衡化 gamma调整.sigmoid调整.log调整 判断图像是否对比度太低 exposure模块包括以下函数: histogram 统计颜色的直方图,基于nump ...

  3. [转]Vue生态系统中的库

    Vue UI组件库 Vuex vux github ui demo:https://github.com/airyland/vux Mint UI 项目主页:http://mint-ui.github ...

  4. MM 算法与 EM算法概述

    1.MM 算法: MM算法是一种迭代优化方法,利用函数的凸性来寻找它们的最大值或最小值. MM表示 “majorize-minimize MM 算法” 或“minorize maximize MM 算 ...

  5. 【LeetCode】79. Word Search

    Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constr ...

  6. Microsoft Office2003打开office2007文件的补丁

    Microsoft  office2003打开office2007,不需要安装2007,只需要装一个补丁即可 搜索:office2003打开office2007文件的补丁

  7. RHEL6.4 NFS文件共享服务器搭建

    服务端:192.168.56.16客户端:192.168.56.17 服务端安装配置1.安装软件包 # yum install rpcbind nfs-utils 2.配置开机自启动 # chkcon ...

  8. OAF_OAF增删改-新增的实现(案例)

    2014-09-14 Created By BaoXinjian

  9. android适配器Adapter

    一.什么是适配器,适配器有什么用? 适配器是AdapterView视图(如ListView - 列表视图控件.Gallery - 缩略图浏览器控件.GridView - 网格控件.Spinner - ...

  10. iOS9中怎样在日历App中创建一个随意时间之前開始的提醒(三)

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 假设认为写的不好请多提意见,假设认为不错请多多支持点赞.谢谢! hopy ;) 四.创建随意时间之前開始的提醒 如今我们找到了指定源中的指定日 ...