Method _ JQuery

Source: Internet
Author: User
This article mainly introduces JQuery's method for encapsulating DOM nodes. The example analyzes the techniques and precautions for using the wrap and wrapAll methods to wrap DOM nodes, for more information about how to wrap DOM nodes in JQuery, see the example in this article. Share it with you for your reference. The specific analysis is as follows:

If you want to wrap a node with other tags, JQuery provides the corresponding method, namely, wrap (), which is very useful for inserting additional structured tags in the document, and it does not break the semantics of the original document.

Wrap ()

The code is as follows:

$ ("# Li_1"). wrap ("");

The result is as follows:

  
  • Simple PHP programming
  • The package node operation has two other methods: wrapAll () and wrapInner ().

    WrapAll () method

    This method will wrap all matching elements with one element. Unlike the wrap () method, The wrap () method packages all elements separately. The JQuery code is as follows:

    The code is as follows:

    $ (". Li_2"). wrapAll ("");

    The HTML wrapped in the wrapAll () method is as follows:

      
  • Easy-to-understand C Programming
  • Simple and easy-to-understand JavaScript programming
  • WrapInner () method

    This method wraps the child content (including text nodes) of each matching element with other structured tags.

    The code is as follows:

    $ ("# Li_4"). wrapInner ("");

    After running the codeThe content in the tag is a pair

  • The result is as follows:

  • Simple and easy-to-understand JQuery programming
  • The JQuery code in this example is as follows:

  • 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.