$ (this). The parent (). Parent (). Parent (). Remove (). This method is looked up through the parent () level
$ (this). Parents ("div"). Remove ();//This method is to find all the parent elements and ancestor elements through the "div" to filter out the ancestors of the ancestral elements of the Div
A parent is a collection of elements that gets a unique parent element that contains all the matching elements. Parents is a collection of elements (without the root element) that has an ancestor element that contains all the matching elements. You can filter by an optional expression. The parent made it very clear that the current element parents is the ancestor element of the current element--<HTML> <Head></Head> <Body> <DivID= "Div1"> <DivID= "Div2"><P></P></Div> <DivID= "Div3"class= "a"><P></P></Div> <DivID= "Div4"><P></P></Div> </Div> </Body> <Scripttype= "Text/javascript"src= "Jquery-1.7.1.min.js"></Script> <Scripttype= "Text/javascript"> $("P"). parent (); //the Div2, Div3 and Div4 were obtained. $('P'). Parent ('. A'); //obtained is Div3 $('P'). Parent (). parent (); //The acquisition is DIV1 (this is strange, but the nature of the jquery object itself determines that this is possible) $('P'). Parents (); //the Div1, Div2, Div3 and Div4 were obtained. $('P'). Parents ('. A'); //the Div3 was made. </Script> </HTML>
JQuery uses the parent () parents () to look for parents or ancestor elements