Ext.query(“*[class=bar]”);
// 这会得到class不等于“bar”的所有元素
Ext.query(“*[class!=bar]”);
// 这会得到class从“b”字头开始的所有元素
Ext.query(“*[class^=b]”);
//这会得到class由“r”结尾的所有元素
Ext.query(“*[class$=r]”);
//这会得到在class中抽出“a”字符的所有元素
Ext.query(“*[class*=a]”);//这会得到name等于“BlueLotus7”的所有元素
Ext.query(“*[name=BlueLotus7]”);
我们换个html代码:
<html>
<head>
</head>
<body>
<div id=”bar” class=”foo” style=”color:red;”>
我是一个div ==> 我的id是: bar, 我的class: foo
<span class=”bar” style=”color:pink;”>I’m a span within the div with a foo class</span>
<a href=”http://www.extjs.com” target=”_blank” style=”color:yellow;”>An ExtJs link with a blank target!</a>
</div>
<div id=”foo” class=”bar” style=”color:fushia;”>
my id: foo, my class: bar
<p>I’m a P tag within the foo div</p>
<span class=”bar” style=”color:brown;”>I’m a span within the div with a bar class</span>
<a href=”#” style=”color:green;”>An internal link</a>
</div>
</body>
</html>
// 获取所以红色的元素
Ext.query(“*{color=red}”); // [div#bar.foo]
// 获取所有粉红颜色的并且是有红色子元素的元素
Ext.query(“*{color=red} *{color=pink}”); // [span.bar]
// 获取所有不是红色文字的元素
Ext.query(“*{color!=red}”); // [html, head, script firebug.js, link, body#ext-gen2.ext-gecko, script ext-base.js, script ext-core.js, span.bar, a www.extjs.com, div#foo.bar, p, span.bar, a test.html#]
// 获取所有颜色属性是从“yel”开始的元素
Ext.query(“*{color^=yel}”); // [a www.extjs.com]
// 获取所有颜色属性是以“ow”结束的元素
Ext.query(“*{color$=ow}”); // [a www.extjs.com]
// 获取所有颜色属性包含“ow”字符的元素
Ext.query(“*{color*=ow}”); // [a www.extjs.com, span.bar]
(5)伪操作符取法换个html:
<html>
<head>
</head>
<body>
<div id=”bar” class=”foo” style=”color:red; border: 2px dotted red; margin:5px; padding:5px;”>
我是一个div ==> 我的id是bar,我的class是foo
<span class=”bar” style=”color:pink;”>这里是span元素,外层的div元素有foo的class属性</span>
<a href=”http://www.extjs.com” target=”_blank” style=”color:yellow;”>设置blank=target的ExtJS链接</a>










