Record--jquery get parent, child, sibling element + instance

Source: Internet
Author: User

The requirements are as follows:

Three data, click on one of the data below to show the pictures associated with this data. The main function may be to add the display line under the data clicked

Ideas:

Hide, click, and then display the data you want to add.

Knowledge Points:

Jquery.parent (expr)//Find the Father node, you can pass in expr for filtering, such as $ ("span"). Parent () or $ ("span"). Parent (". Class") jquery.parents (expr)// Similar to jquery.parents (expr), but is to find all ancestor elements, not limited to the parent element Jquery.children (expr)//Return all child nodes, this method will only return the direct child node, Does not return all descendant nodes jquery.contents ()//return all content below, including nodes and text. The difference between this method and children () is that including blank text, which is also returned as a jquery object, children () returns only the node Jquery.prev ()//returns to the previous sibling node, Not all Brothers node Jquery.prevall ()//Return all previous sibling nodes Jquery.next ()//return to the next sibling node, not all sibling nodes Jquery.nextall ()// Return all subsequent sibling nodes jquery.siblings ()//Return sibling nodes, Jquery.find (expr)  ///with Jquery.filter (expr) is completely different. Jquery.filter () is a partial filter from the initial set of JQuery objects, and the returned result of Jquery.find () does not have the contents of the initial collection, such as $ ("P"), Find ("span"), which is the start of the P element, equivalent to $ ("p Span ").

Instance:

<Scripttype= "Text/javascript">    $(function(){            })        functionDJ (obj) {$ (obj). Parent (). Parent (). Next (). Children ('. TP'). Show (); $ (obj). Parent (). Parent (). Next (). siblings (). Children ('. TP'). Hide (); }</Script><DivID= "Table">    <Tablewidth= "500px"Border= "1px">        <thead>            <TR>                <th>Id</th>                <th>Conditions</th>                <th>Name</th>            </TR>        </thead>        <tbody>            <TR>                <TD>13335555</TD>                <TD>Fold</TD>                <TD><ahref= "javascript:void (0)"onclick= "DJ (This)">Love</a></TD>            </TR>            <TR>                <TDclass= "TP"colspan= "3"><imgsrc=""alt= "Tup"/></TD>            </TR>            <TR>                <TD>2</TD>                <TD>Fold</TD>                <TD><ahref= "javascript:void (0)"onclick= "DJ (This)">Love</a></TD>            </TR>            <TR>                <TDclass= "TP"colspan= "3"><imgsrc=""alt= "Tup"/></TD>            </TR>            <TR>                <TD>3</TD>                <TD>Fold</TD>                <TD><ahref= "javascript:void (0)"onclick= "DJ (This)">Love</a></TD>            </TR>            <TR>                <TDclass= "TP"colspan= "3"><imgsrc=""alt= "Tup"/></TD>            </TR>        </tbody>    </Table></Div>

Record--jquery get parent, child, sibling element + instance

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.