±¾²©ÎļǼÁ˴󲿷ֳ£ÓõÄ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
½ôÁÚÔÚdivºóÃæµÄspan±êÇ©
4.ÐÖµÜÑ¡ÔñÆ÷ div ~ span
>1>2</div> </div> $("span ~ div");//<div>1</div>£¬<div>2</div> »ù±¾É¸Ñ¡Ñ¡ÔñÆ÷1.£ºfirstºÍ£ºlast
»ñÈ¡µÚÒ»¸öºÍ×îºóÒ»¸öÔªËØ
2.£ºgt(index)ºÍ£ºlt(index)
»ñÈ¡±È´óÓÚ/СÓÚË÷ÒýÖµµÄÔªËØ
3.£ºheader£¬±êÌâÔªËصÄÆ¥Åä
>>> $(":header");//> ÄÚÈÝÑ¡ÔñÆ÷1.£ºhas(selector)£¬Æ¥Å京ÓÐÑ¡ÔñÆ÷ËùÆ¥ÅäµÄÔªËصÄÔªËØ
> <div>hi</div> $("div:has(p)");//>2.£ºparent£¬º¬ÓÐ×ÓÔªËØ»òÎı¾µÄÔªËØ
£ºempty£¬²»º¬×ÓÔªËØ»òÎı¾µÄÔªËØ
3.£ºcontains£¨text£©£¬°üº¬¸ø¶¨Îı¾µÄÔªËØ
<div>hello</div> <div>hi</div> $("div:contains('hi')");//<div>hi</div> ¿É¼ûÐÔ:visible£ºÆ¥ÅäËùÓпɼûÔªËØ
:hidden£ºÆ¥ÅäËùżÓö²»¿É¼û»òÕßtypeΪhiddenµÄÔªËØ
1.[attr]£ºÆ¥Åä°üº¬¸ø¶¨ÊôÐÔµÄÔªËØ
> > $("div[id]");//>2.[attr = value]£ºÆ¥Åä¸ø¶¨µÄÊôÐÔÊÇij¸öÌض¨ÖµµÄÔªËØ
[attr != value]£ºÆ¥Åä¸ø¶¨µÄÊôÐÔ²»ÊÇij¸öÌض¨ÖµµÄÔªËØ
3.[attr^ = value]£ºÆ¥Åä¸ø¶¨ÊôÐÔÒÔvalue¿ªÍ·µÄÔªËØ
[attr$ = value]£ºÆ¥Åä¸ø¶¨ÊôÐÔÒÔvalue½áβµÄÔªËØ
[attr* = value]£ºÆ¥Åä¸ø¶¨ÊôÐÔ°üº¬valueµÄÔªËØ
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-child£¬£ºlast-child£¬£ºonly-child
Æ¥ÅäËù¸øÑ¡ÔñÆ÷µÄµÚÒ»¸öÔªËØ£»×îºóÒ»¸öÔªËØ£»Èç¹ûij¸öÔªËØÊǸ¸ÔªËØÖÐΨһµÄ×ÓÔªËØ£¬Äǽ«»á±»Æ¥Åä
¡¡