cssQuery()的下载与使用方法
cssQuery()的下载与使用方法
发布时间:2016-12-30 来源:查字典编辑
摘要: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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类