Summary of jquery's method for moving dom nodes

Source: Internet
Author: User

Jquery also occasionally uses dom operations to move DOM nodes. The authors will share with you how to use jQuery to move dom nodes.

Note that moving a dom node is different from copying a dom node. Moving a dom node moves a dom node from one location to another. After moving a dom node, there is only one. The copy dom node will become two after the operation. Below are some examples to explain.

Assume that the page has the following code segment:

<Body> <div> http://www.phpernote.com/javascript-function/586.html </div> <p> jquery dom operation example </p> </body>

To move the <p> label to the <div> label, perform the following operations:

$(function(){$('div').append($('p'));});

After the operation, the html code of the page will look like the following:

<Body> <div> http://www.phpernote.com/javascript-function/586.html <p> jquery dom operation example </p> </div> </body>

The following describes the methods that js uses to operate dom nodes: append, appendTo, prepend, prependTo, after, before, insertAfter, and insertBefore.

Articles you may be interested in
  • Summary of how jquery copies dom nodes
  • How does jquery bind events to dynamically created nodes?
  • Move the mouse over the text to display the floating layer prompt special effects (compatible with all browsers such as IE and Firefox)
  • Js obtains the height of the scroll bar from the top and bottom of the browser. It is compatible with ie and firefox.
  • Insert a node before the current jquery Node
  • JavaScript deletes a DOM Node
  • JQuery DOM node insertion method summary
  • JQuery DOM node insertion method summary

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.