From the b tag in a tag a, that is, the B tag ($ ("#B") from the A tag is the B tag in the entire page, that is, the child label B of the A tag is obtained.
<div id= "a" >
<ul class= "XXX YYY am-list-striped" >
</ul>
<div id= "A1" >
<div id= "A11" >
<input id= "test" value= "Hello"/>
</div>
</div>
<div id= "A2" ></div>
</div>
<div id= "B" ></div>
<div id= "C" ></div>
From the parent tag of the label whose ID is "test", find its class as:
1) the wrong way .
$ ($ ("#test"). Parent (). Parent (). Parent (), "ul[class$= ' am-list-striped"). This is wrong,
Alert ($ ("#test"). Parent (). Parent (). Parent (), "ul[class$= ' am-list-striped ']"). html ());//results are as follows
In this way, the obvious is $ ("#test"). Parent (). Parent (), this sentence does not work "ul[class$= ' am-list-striped '".
This syntax is wrong, so you cannot use this method. The following syntax is the correct way to implement a child tag for a parent tag using the two parameters of the jquery selector:
2) The right way
$ ($ ("#test"). Parent (). Parent (). Parent (), "ul[class$= ' am-list-striped '");//Right way
So
So when you encounter a child tag from a parent tag, use the Find function.
Http://www.jb51.net/article/21660.htm
Https://zhidao.baidu.com/question/571272157.html