How jquery inserts sibling nodes _jquery

Source: Internet
Author: User

Function: Inserts the specified element into the first position of the parent element (leftmost)

Instance

$self. prepend ($selectLi);

Explain

Self is the parent element of Selectli, which puts self at the front of the Selectli (leftmost),

The move is Selectli,

Append

Function: Inserts the specified element to the last face of the parent element (rightmost)

After

Instance

$firstLi. After ($selectLi);

Explain

Put the Selectli on the back of the Firstli (right),

Moving is Selectli.

Note: Selectli and Firstli are sibling nodes

Next

Function: Get the next sibling node,

Contrary to its function is prev

Instance

while ($selectLiYears >firstliyears) {
      $firstLi = $firstLi. Next ();
      Hasexpandclicked=true;
      firstliyears= $firstLi. Data (' years ');
    

explain

Get Next sibling node

Gets the child elements of the specified index

Instance

var $selectLi = $self. Find (' Li:nth-child (' + (Srcindex) + ') ');
var $firstLi = $self. Find (' Li:first ');
$ ("P:nth-child (3)")

Explain

: First indicates that you get the initial element,
: Last means to get the final element,
Nth-child (2) means get 2nd element

Above this jquery inserts the sibling node the operation method is the small series to share to everybody's content, hoped can give everybody a reference, also hoped that everybody supports the cloud habitat community.

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.