DOM operation in JQuery - wrap

jacklove
Release: 2018-06-11 22:27:38
Original
2030 people have browsed it

wrap: wrap, the usage is $(a).wrap((b)); Wrap a with b (each element will be wrapped)

For example: in body There are three p

	

p1

p2

p3

Copy after login

Now perform the wrapping operation on p:

$("p").wrap("

");
Copy after login

The corresponding output is

unwrap: Unwrap

For example, now unwrap the three p’s above:

$("p").unwrap();
Copy after login

wrapAll: All elements are wrapped (all elements will be wrapped together)

For example: perform wrapAll operation on the above three p

$("p").wrapAll("

");
Copy after login

The output is:


wrapInner: inner wrap

This is to rebuild a new element at the next level inside the element and put all the contents of the parent element Wrap; look directly at the example:

Now there is a p with content and elements inside;

p1 连接

Copy after login

We perform wrapInner operations on it:

$("p").wrapInner('

');
Copy after login

The output is:



## From this point of view, the inner operation in jquery is very clear.

This article explains the DOM operation in JQuery - wrap related knowledge. For more related content, please pay attention to the php Chinese website.

Related recommendations:


django uses request to obtain the parameters sent by the browser

Some thoughts on React this binding

The problem of passing value from parent component to child component echarts in vue

The above is the detailed content of DOM operation in JQuery - wrap. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!