On the difference between wrap () Wrapall () and Wrapinner () in jquery _jquery

Source: Internet
Author: User

When I read tonight, I found out that jquery has three package nodes, and Baidu has a bit of jquery wrap ()/Wrapall ()/Wrapinner (), and sure enough the search results W3school document description is the first.

However, W3school's explanation is this:

JQuery Document Manipulation-wrap () method

The Wrap () method places each selected element in the specified HTML content or element.
JQuery Document Manipulation-Wrapall () method

Wrapall () places all the selected elements in the specified HTML content or element.
JQuery Document Manipulation-Wrapinner () method

The Wrapinner () method wraps all content (inner HTML) in each selected element using the specified HTML content or element.
I read fewer books, and it was annoying to see such an explanation not to solve my confusion immediately.

or the most practical.

This is used to compare the original code:

<p> I am a seat. </p>
<p> I am a seat. </p>
Wrap () method

$ ("P"). Wrap ("<strong></strong>");

Results:

You can see from the diagram that the strong tag encloses each matching p tag.

Wrapall () method

$ ("P"). Wrapall ("<strong></strong>");

Results:

As you can see from the diagram, the strong tag encloses all of the matching P tags all of a sudden.

Wrapinner () method

$ ("P"). Wrapinner ("<strong></strong>");

Results:

You can see from the diagram that the strong tag is embedded inside each matching p tag.

Of course, at last it looks like the effect of three methods is the same.

Point to stop.

That is the difference between the individual and The Wrap () Wrapall () and Wrapinner () in jquery, just a personal understanding of the great God please skip.

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.