From the b tag in a tag a, i.e. select the B tag from the A tag ($ ("#B") to get the B tag in the entire page), that is, get the child label B of the A tag, how to get it?

Source: Internet
Author: User

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




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.