DOM operation in JQuery - wrap

jacklove
Release: 2018-06-11 22:27:38
Original
2427 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

	<p>p1</p>
	<p>p2</p>
	<p>p3</p>
Copy after login

Now perform the wrapping operation on p:

$("p").wrap("<p></p>");
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("<p></p>");
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;

<p>p1 <a href="" title="">连接</a></p>
Copy after login

We perform wrapInner operations on it:

$("p").wrapInner(&#39;<p></p>&#39;);
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