手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >cssQuery()的下载与使用方法
cssQuery()的下载与使用方法
摘要:IntroductioncssQuery()isapowerfulcross-browserJavaScriptfunctionthaten...

Introduction

cssQuery()isapowerfulcross-browserJavaScriptfunctionthatenablesqueryingofaDOMdocumentusingCSSselectors.AllCSS1andCSS2selectorsareallowedplusquiteafewCSS3selectors.

Usage

Syntax

elements=cssQuery(selector[,from]);whereselector(required)isavalidCSSselectorandfrom(optional)isadocument,elementorarrayofelementswhichisfilteredbyselector.

ThefunctionreturnsaJavaScriptarrayofelements.Ifthereisnomatch,anemptyarrayisreturned.

Someexamples:

//findallparagraphsthataredirectdescendants//ofthedocumentbodyvartags=cssQuery("body>p");//findallelementswiththe"href"attributevartags=cssQuery("[href]");//findallanchorelementswith"href"equalto"#"vartags=cssQuery("a[href='#']");//findallimagescontainedbytheaboveanchorsvarimages=cssQuery("img",tags);//findalllistsvartags=cssQuery("dl,ol,ul");//queryanexternalxmldocumentvartags=cssQuery("my|:root>my|link",myXMLDoc);//justplaincomplicatedvarcomplex="p>a:first-child+input[type=text]~span";vartags=cssQuery(complex);AllowedSelectors

*

E

EF

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

Knowntoworkonthefollowingplatforms:

MicrosoftInternetExplorer5+(Windows)

MicrosoftInternetExplorer5.2(Mac)

Firefox/Mozilla1.6+

Opera7+

Netscape6+

Safari1.2

Source Code cssQuery.js cssQuery-level2.js cssQuery-level3.js cssQuery-standard.js

【cssQuery()的下载与使用方法】相关文章:

JQuery中基础过滤选择器用法

在JavaScript中使用NaN值的方法

jQuery取消ajax请求的方法

jQuery预加载图片常用方法

JavaScript中search()方法的使用

jQuery处理图片加载失败的常用方法

JavaScript中this关键字使用方法详解

JQuery给网页更换皮肤的方法

jQuery实现延迟跳转的方法

JQuery中上下文选择器实现方法

精品推荐
分类导航