<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "Utf-8"> <Linkhref= "Style/css.css"rel= "stylesheet"type= "Text/css" /> <Scriptsrc= "Js/jquery-1.7.2.min.js"></Script> <Script>$ (document). Ready (function(){ $(". HREF_FIV"). Parent (). AddClass ("Div1"); $(". HREF_FIV"). CSS ("Color","Red"); //$ (". Div2"). AddClass ("Div1"); }); </Script> </Head> <Body> <DivID= "Par_div"> <aID= "Href_fir"href="#">Href_fir</a> <aID= "Href_sec"href="#">Href_sec</a> <aID= "Href_thr"href="#">Href_thr</a> </Div> <Divclass= "Div2"> <spanID= "Par_span"> <aclass= "HREF_FIV"href="#">Href_fiv</a> </span> </Div> </Body></HTML>
1,jquery the parent element of the selector (); Gets only the previous level of a father, that is, only the Par_span is obtained, and not the DIV2
What is the difference between 2,html and descendant elements?
For example
<ul>//, I'm grandpa haha.
<li>//I'm a dad,
<a href= "" >hi,mofe</a>//I am the descendant element of UL, the child element of Li
</li>
<ul>
Generational elements are called descendant elements
jquery selector Gets the parent element, child element, sibling element