Ô´ÂëÍø,Ô´ÂëÂÛ̳,Ô´ÂëÖ®¼Ò,ÉÌÒµÔ´Âë,ÓÎÏ·Ô´ÂëÏÂÔØ,discuz²å¼þ,ÆåÅÆÔ´ÂëÏÂÔØ,¾«Æ·Ô´ÂëÂÛ̳

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á
²é¿´: 275|»Ø¸´: 18

[JavaScript] juqery ѧϰ֮Èý Ñ¡ÔñÆ÷ ²ã¼¶ »ù±¾

[¸´ÖÆÁ´½Ó]

7Íò

Ö÷Ìâ

861

»ØÌû

32Íò

»ý·Ö

ÂÛ̳ԪÀÏ

Rank: 8Rank: 8

»ý·Ö
329525
·¢±íÓÚ 2010-11-25 18:39:34 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ
juqery ѧϰ֮Èý Ñ¡ÔñÆ÷ ²ã¼¶ »ù±¾£¬Ñ§Ï°jqueryµÄÅóÓÑ¿ÉÒԲο¼Ï¡£

#id

¸ù¾Ý¸ø¶¨µÄIDÆ¥ÅäÒ»¸öÔªËØ¡£
Matches a single element with the given id attribute.

·µ»ØÖµ

Element

²ÎÊý

id (String) : ÓÃÓÚËÑË÷µÄ£¬Í¨¹ýÔªËØµÄ id ÊôÐÔÖиø¶¨µÄÖµ

ʾÀý

²éÕÒ ID Ϊ"myDiv"µÄÔªËØ¡£

HTML ´úÂë:

<div id="notMe"><p>id="notMe"</p></div>
<div id="myDiv">id="myDiv"</div>

jQuery ´úÂë:

$("#myDiv");

½á¹û:

[ <div id="myDiv">id="myDiv"</div> ]
---------------------------------------------------------------------------------------

element

¸ù¾Ý¸ø¶¨µÄÔªËØÃûÆ¥ÅäËùÓÐÔªËØ
Matches all elements with the given name.

·µ»ØÖµ

Array<Element>

²ÎÊý

element (String) : Ò»¸öÓÃÓÚËÑË÷µÄÔªËØ¡£Ö¸Ïò DOM ½ÚµãµÄ±êÇ©Ãû¡£

ʾÀý

²éÕÒÒ»¸ö DIV ÔªËØ¡£

HTML ´úÂë:

<div>DIV1</div>
<div>DIV2</div>
<span>SPAN</span>

jQuery ´úÂë:

$("div");

½á¹û:

[ <div>DIV1</div>, <div>DIV2</div> ] ---------------------------------------------------------------------------------------

.class

¸ù¾Ý¸ø¶¨µÄÀàÆ¥ÅäÔªËØ¡£
Matches all elements with the given class.

·µ»ØÖµ

Array<Element>

²ÎÊý

class (String) : Ò»¸öÓÃÒÔËÑË÷µÄÀà¡£Ò»¸öÔªËØ¿ÉÒÔÓжà¸öÀֻ࣬ҪÓÐÒ»¸ö·ûºÏ¾ÍÄܱ»Æ¥Åäµ½¡£

ʾÀý

²éÕÒËùÓÐÀàÊÇ "myClass" µÄÔªËØ.

HTML ´úÂë:

<div class="notMe">div class="notMe"</div>
<div class="myClass">div class="myClass"</div>
<span class="myClass">span class="myClass"</span>

jQuery ´úÂë:

$(".myClass");

½á¹û:

[ <div class="myClass">div class="myClass"</div>, <span class="myClass">span class="myClass"</span> ]
---------------------------------------------------------------------------------------

*

Æ¥ÅäËùÓÐÔªËØ ¶àÓÃÓÚ½áºÏÉÏÏÂÎÄÀ´ËÑË÷¡£
Matches all elements. Most useful when combined with a context to search in.

·µ»ØÖµ

Array<Element>

ʾÀý

ÕÒµ½Ã¿Ò»¸öÔªËØ

HTML ´úÂë:

<div>DIV</div>
<span>SPAN</span>
<p>P</p>

jQuery ´úÂë:

$("*")

½á¹û:

[ <div>DIV</div>, <span>SPAN</span>, <p>P</p> ]
---------------------------------------------------------------------------------------

selector1,selector2,selectorN

½«Ã¿Ò»¸öÑ¡ÔñÆ÷Æ¥Åäµ½µÄÔªËغϲ¢ºóÒ»Æ𷵻ء£ Äã¿ÉÒÔÖ¸¶¨ÈÎÒâ¶à¸öÑ¡ÔñÆ÷£¬²¢½«Æ¥Åäµ½µÄÔªËغϲ¢µ½Ò»¸ö½á¹ûÄÚ¡£
Matches the combined results of all the specified selectors. You can specify any number of selectors to combine into a single result.

·µ»ØÖµ

Array<Element>

²ÎÊý

selector1 (Selector) : Ò»¸öÓÐЧµÄÑ¡ÔñÆ÷

selector2 (Selector) : ÁíÒ»¸öÓÐЧµÄÑ¡ÔñÆ÷

selectorN (Selector) : (¿ÉÑ¡) ÈÎÒâ¶à¸öÓÐЧѡÔñÆ÷

ʾÀý

ÕÒµ½Æ¥ÅäÈÎÒâÒ»¸öÀàµÄÔªËØ¡£

HTML ´úÂë:

<div>div</div>
<p class="myClass">p class="myClass"</p>
<span>span</span>
<p class="notMyClass">p class="notMyClass"</p>

jQuery ´úÂë:

$("div,span,p.myClass")

½á¹û:

[ <div>div</div>, <p class="myClass">p class="myClass"</p>, <span>span</span> ] ---------------------------------------------------------------------------------------

ancestor descendant

ÔÚ¸ø¶¨µÄ×æÏÈÔªËØÏÂÆ¥ÅäËùÓеĺó´úÔªËØ
Matches all descendant elements specified by descendant of elements specified by ancestor.

·µ»ØÖµ

Array<Element>

²ÎÊý

ancestor (Selector) : ÈκÎÓÐЧѡÔñÆ÷

descendant (Selector) : ÓÃÒÔÆ¥ÅäÔªËصÄÑ¡ÔñÆ÷£¬²¢ÇÒËüÊǵÚÒ»¸öÑ¡ÔñÆ÷µÄºó´úÔªËØ

ʾÀý

ÕÒµ½±íµ¥ÖÐËùÓÐµÄ input ÔªËØ

HTML ´úÂë:

<form>
  <label>Name:</label>
  <input name="name" />
  <fieldset>
      <label>Newsletter:</label>
      <input name="newsletter" />
 </fieldset>
</form>
<input name="none" />

jQuery ´úÂë:

$("form input")

½á¹û:

[ <input name="name" />, <input name="newsletter" /> ]
---------------------------------------------------------------------------------------

parent > child

ÔÚ¸ø¶¨µÄ¸¸ÔªËØÏÂÆ¥ÅäËùÓеÄ×ÓÔªËØ
Matches all child elements specified by child of elements specified by parent.

·µ»ØÖµ

Array<Element>

²ÎÊý

parent (Selector) : ÈκÎÓÐЧѡÔñÆ÷

child (Selector) : ÓÃÒÔÆ¥ÅäÔªËصÄÑ¡ÔñÆ÷£¬²¢ÇÒËüÊǵÚÒ»¸öÑ¡ÔñÆ÷µÄ×ÓÔªËØ

ʾÀý

Æ¥Åä±íµ¥ÖÐËùÓеÄ×Ó¼¶inputÔªËØ¡£

HTML ´úÂë:

<form>
  <label>Name:</label>
  <input name="name" />
  <fieldset>
      <label>Newsletter:</label>
      <input name="newsletter" />
 </fieldset>
</form>
<input name="none" />

jQuery ´úÂë:

$("form > input")

½á¹û:

[ <input name="name" /> ]
---------------------------------------------------------------------------------------

prev + next

Æ¥ÅäËùÓнô½ÓÔÚ prev ÔªËغóµÄ next ÔªËØ
Matches all next elements specified by next that are next to elements specified by prev.

·µ»ØÖµ

Array<Element>

²ÎÊý

prev (Selector) : ÈκÎÓÐЧѡÔñÆ÷

next (Selector) :Ò»¸öÓÐЧѡÔñÆ÷²¢ÇÒ½ô½Ó×ŵÚÒ»¸öÑ¡ÔñÆ÷

ʾÀý

Æ¥ÅäËùÓиúÔÚ label ºóÃæµÄ input ÔªËØ

HTML ´úÂë:

<form>
  <label>Name:</label>
  <input name="name" />
  <fieldset>
      <label>Newsletter:</label>
      <input name="newsletter" />
 </fieldset>
</form>
<input name="none" />

jQuery ´úÂë:

$("label + input")

½á¹û:

[ <input name="name" />, <input name="newsletter" /> ]
---------------------------------------------------------------------------------------

prev ~ siblings

Æ¥Åä prev ÔªËØÖ®ºóµÄËùÓÐ siblings ÔªËØ
Matches all sibling elements after the "prev" element that match the filtering "siblings" selector.

·µ»ØÖµ

Array<Element>

²ÎÊý

prev (Selector) : ÈκÎÓÐЧѡÔñÆ÷

siblings (Selector) : Ò»¸öÑ¡ÔñÆ÷£¬²¢ÇÒËü×÷ΪµÚÒ»¸öÑ¡ÔñÆ÷µÄͬ±²

ʾÀý

ÕÒµ½ËùÓÐÓë±íµ¥Í¬±²µÄ input ÔªËØ

HTML ´úÂë:

<form>
  <label>Name:</label>
  <input name="name" />
  <fieldset>
      <label>Newsletter:</label>
      <input name="newsletter" />
 </fieldset>
</form>
<input name="none" />

jQuery ´úÂë:

$("form ~ input")

½á¹û:

[ <input name="none" /> ]
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

3

Ö÷Ìâ

2Íò

»ØÌû

301

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
301
·¢±íÓÚ 2022-10-28 03:58:29 | ÏÔʾȫ²¿Â¥²ã
ÄãÃÇË­¿´ÁËŪÈ÷ÁË¿ÉÄÜ

4

Ö÷Ìâ

1Íò

»ØÌû

60

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
60
·¢±íÓÚ 2023-2-9 08:18:19 | ÏÔʾȫ²¿Â¥²ã
µÄË­vdvdsvdsvdsdsv

0

Ö÷Ìâ

2Íò

»ØÌû

186

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
186
·¢±íÓÚ 2023-5-5 10:27:09 | ÏÔʾȫ²¿Â¥²ã
¸ø°Ö°Ö°Ö°Ö°Ö°Ö°Ö°Ö°Ö°Ö°Ë°Û°é°Ë°Û°é

1

Ö÷Ìâ

2Íò

»ØÌû

182

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
182
·¢±íÓÚ 2023-10-18 16:56:34 | ÏÔʾȫ²¿Â¥²ã
ºÜ²»´íµÄÑù×Ó

0

Ö÷Ìâ

1Íò

»ØÌû

87

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
87
·¢±íÓÚ 2023-11-6 15:46:32 | ÏÔʾȫ²¿Â¥²ã
66666666666666666666

2

Ö÷Ìâ

2Íò

»ØÌû

381

»ý·Ö

Ö춻áÔ±

Rank: 3Rank: 3

»ý·Ö
381
·¢±íÓÚ 2023-11-18 00:34:33 | ÏÔʾȫ²¿Â¥²ã
554411515451555

1

Ö÷Ìâ

1Íò

»ØÌû

51

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
51
·¢±íÓÚ 2023-12-12 14:50:15 | ÏÔʾȫ²¿Â¥²ã
¼¤¶¯ÈËÐÄ£¬ÎÞ·¨ÑÔ±í£¡

0

Ö÷Ìâ

2Íò

»ØÌû

124

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
124
·¢±íÓÚ 2024-3-9 21:10:32 | ÏÔʾȫ²¿Â¥²ã
·É·É·É·É·É·É·É·É·É·É·É·É·É

0

Ö÷Ìâ

2Íò

»ØÌû

115

»ý·Ö

×¢²á»áÔ±

Rank: 2

»ý·Ö
115
·¢±íÓÚ 2024-4-13 20:10:59 | ÏÔʾȫ²¿Â¥²ã
À²À²À²À²À²À²À²À²£¡
¸ß¼¶Ä£Ê½
B Color Image Link Quote Code Smilies

±¾°æ»ý·Ö¹æÔò

ÊÖ»ú°æ|СºÚÎÝ|ÍøÕ¾µØͼ|Ô´ÂëÂÛ̳ ( º£Íâ°æ )

GMT+8, 2024-11-22 02:25 , Processed in 0.242785 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí