: First: Select the element that appears to match
: first-child: Select the first element in the constraint and must match the label preceding the colon
: First-of-type: Select the label element in front of the first colon under all restrictions, this label may not be the first
Test: First Code:
<Body><a></a><P>1</P><P>2</P><P>3</P><Div><a>Hello1</a><P>Hello2</P><P>Hello3</P></Div><Div><P>Hello4</P><P>Hello5</P><P>Hello6</P></Div><Div></Div><Script> $(function() {$zzz=$("P:first"). text (); alert ($zzz);});</Script>
</body>
The result is:
Test: First-child Code:
<Body><a></a><P>1</P><P>2</P><P>3</P><Div><a>Hello1</a><P>Hello2</P><P>Hello3</P></Div><Div><P>Hello4</P><P>Hello5</P><P>Hello6</P></Div><Div></Div><Script> $(function() {$zzz=$("P:first-child"). text (); alert ($zzz);});</Script></Body>
The result is:
Test: First-of-type Code:
<Body><a></a><P>1</P><P>2</P><P>3</P><Div><a>Hello1</a><P>Hello2</P><P>Hello3</P></Div><Div><P>Hello4</P><P>Hello5</P><P>Hello6</P></Div><Div></Div><Script> $(function() {$zzz=$("P:first-of-type"). text (); alert ($zzz);});</Script></Body>
The result is:
How, well understand, study the long time!
About the jquery suspension: First and: First-child and: First-of-type differences