当前位置: 首页 > 图文教程 > 网络编程 > Javascript > cssQuery()的下载与使用方法

Javascript
javascript 汉字与拼音转换
JavaScript使用cookie
大平洋汽车网左侧菜单
使用JS操作页面表格,元素的一些技巧
分享我学习js的过程 作者aircy javascript学习教程
张孝祥JavaScript学习阶段性总结(2)--(X)HTML学习
用js来生成随机彩票号码清单
发一个数据过滤的代码,很简单,有用的着的拿去
如何在标题栏显示框架内页面的标题
js滚动条多种样式,推荐
再次更新!MSClass (Class Of Marquee Scroll通用不间断滚动JS封装类 Ver 1.6)
符合web标准的连续滚动图像的js代码
使用iframe作为日历的载体,不再被select和flash等控件挡住的日期输入框
通过脚本控制指定内容不能被选择
模拟弹出窗口效果,关闭层之前,不能选择后面的页内容
另类弹出窗口,跳过所有拦截工具
使用prototype.js进行异步操作
JS模拟多线程
动态增加/删除文件域
[分享]一个非常漂亮的进度滚动条

Javascript 中的 cssQuery()的下载与使用方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 85 ::
收藏到网摘: n/a

Introduction
cssQuery() is a powerful cross-browser JavaScript function that enables querying of a DOM document using CSS selectors. All CSS1 and CSS2 selectors are allowed plus quite a few CSS3 selectors.
Usage
Syntax
elements = cssQuery(selector [, from]);where selector (required) is a valid CSS selector and from (optional) is a document, element or array of elements which is filtered by selector.
The function returns a JavaScript array of elements. If there is no match, an empty array is returned.
Some examples:
// find all paragraphs that are direct descendants// of the document bodyvar tags = cssQuery("body > p");// find all elements with the "href" attributevar tags = cssQuery("[href]");// find all anchor elements with "href" equal to "#"var tags = cssQuery("a[href='#']");// find all images contained by the above anchorsvar images = cssQuery("img", tags);// find all listsvar tags = cssQuery("dl,ol,ul");// query an external xml documentvar tags = cssQuery("my|:root>my|link", myXMLDoc);// just plain complicatedvar complex = "p>a:first-child+input[type=text]~span";var tags = cssQuery(complex);Allowed Selectors
*
E
E F
E > F
E + F
E ~ F
E.warning
E#myid
E:link
E:first-child
E:last-child
E:nth-child(n)
E:nth-last-child(n)
E:only-child
E:root
E:lang(fr)
E:target
E:enabled
E:disabled
E:checked
E:contains("foo")
E:not(s)
E[foo]
E[foo="bar"]
E[foo~="bar"]
E[foo^="bar"]
E[foo$="bar"]
E[foo*="bar"]
E[foo|="bar"]
Compatibility
Known to work on the following platforms:
Microsoft Internet Explorer 5+ (Windows)
Microsoft Internet Explorer 5.2 (Mac)
Firefox/Mozilla 1.6+
Opera 7+
Netscape 6+
Safari 1.2

Source Code