Home >Web Front-end >Front-end Q&A >DOM operation in JQuery - wrap

DOM operation in JQuery - wrap

jacklove
jackloveOriginal
2018-06-11 22:27:382490browse

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>

Now perform the wrapping operation on p:

$("p").wrap("<p></p>");

The corresponding output is

unwrap: Unwrap

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

$("p").unwrap();

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>");

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>

We perform wrapInner operations on it:

$("p").wrapInner(&#39;<p></p>&#39;);

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!

Statement:
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