jQuery

jQueryѧϰ֮һ

ֺ+ ߣH5֮ ԴH5֮ 2017-12-12 11:19 Ҫ( )

ļ¼˴󲿷ֳõjqѡҪСԹһŶһ½½ĸϵͳjqģһͰɣѡ1.idѡͨidȡ div id=

ļ¼˴󲿷ֳõjqѡҪСԹһŶһ½½ĸϵͳjqģһͰɣ

ѡ

1.idѡͨidȡ

> $("$div");//>

2.elementǩѡ

<div></div> $("div");//<div></div>

3.ѡͨѡȡ

> $(".div");//>

4.*ͳѡƥԪ

></span> $("*");//></span>

5.Ⱥѡÿһѡƥ䵽Ԫغϲһ𷵻

> > <p></p> $("div#div,p");//>,<p></p> 㼶ѡ

1.ѡ div span

> > $("div span");//<span>1</span>,<span>2</span>

2.Ӵѡ div>span

>1>2> $(".div span");//<span>1</span> ע۲죬ʱڶspanǩΪdivӼŶԲ

3.ֵѡ div + span
divspanǩ

>1> > $("span + div");//<div>1</div>

4.ֵѡ div ~ span

>1>2</div> </div> $("span ~ div");//<div>1</div><div>2</div> ɸѡѡ

1.firstͣlast
ȡһһԪ

>2> $("li:first");//<li>1</li> $("li:last");//<li>3</li>

2.gt(index)ͣlt(index)
ȡȴ/СֵԪ

>2> $("li:gt(1)");//<li>3</li> $("li:lt(2));//<li>1</li>

3.headerԪصƥ

>>> $(":header");//> ѡ

1.has(selector)ƥ京ѡƥԪصԪ

> <div>hi</div> $("div:has(p)");//>

2.parentԪػıԪ
emptyԪػıԪ

> > $("div:parent");//>,<div>hi</div> $("div:empty");//<div></div>

3.containstextıԪ

<div>hello</div> <div>hi</div> $("div:contains('hi')");//<div>hi</div> ɼ

:visibleƥпɼԪ
:hiddenƥżɼtypeΪhiddenԪ

> <div></div> $("div:visible");//<div></div> $("div:hidden");//> ѡ

1.[attr]ƥԵԪ

> > $("div[id]");//>

2.[attr = value]ƥijضֵԪ
[attr != value]ƥԲijضֵԪ

> > $("div[id = 'test1']");//> $("div[id != 'test1']");//>

3.[attr^ = value]ƥvalueͷԪ
[attr$ = value]ƥvalueβԪ
[attr* = value]ƥ԰valueԪ

> > > $("div[id* = '1']");//> $("div[id^ = 'new']");//> $("div[id$ = 'Girl']");//> Ԫѡ

1.nth-child()ƥ丸ԪµĵNӻżԪ

>Karl> >Tane> $("ul li:nth-child(2)");//<li>Karl</li>,<li>Tane</li> ͬбǩ˳ĵڶ

2.nth-of-type()ѡͬһԪ֮£ұǩͬԪеĵn

>>> $("li:nth-of-type(2)");//<li>Karl</li> ֻҪͬǩĵڼɣںмûıǩ

3.first-childlast-childonly-child
ƥѡĵһԪأһԪأijԪǸԪΨһԪأǽᱻƥ

>Karl> >Tane> > $("ul li:first-child");// <li>John</li>, <li>Glen</li> $("ul li:last-child");// <li>Brandon</li>, <li>Ralph</li> $("ul li:only-child");//<li>Mike</li>

1.վѭҵ淶κתصĸȷעߺԴ2.վԭ£תʱעߺԴԭΪǽ׷Σ3.ͶܻᾭDZ༭޸Ļ򲹳䡣

  • jquery无new构建学习笔记

    jquery无new构建学习笔记

    2017-12-11 17:19

  • 5jQueryͼ

    5jQueryͼ

    2017-12-11 11:00

  • jQuery Ž̳(11):

    jQuery Ž̳(11):

    2017-12-10 14:11

  • һjqueryͼƬЧ

    һjqueryͼƬЧ

    2017-12-10 10:28

ѵ