Wrap ()
The Wrap () function can accept any string or object that can be passed to the $ () factory function to specify a DOM structure. This structure can be nested several layers deep, but should contain only one core element. Each matching element will be wrapped in this structure. The method returns the original set of elements so that the chained method is used later.
eg
Appends a newline label to the current page and the specified HTML content
function W (html) {
Document.body.innerHTML = "<br/>" + html;
}
var name = "Hello";
function foo (A, b) {
w (this.name);
W (a + b);
}
Call
foo (1, 2) directly;
Hello
//3
var obj = {name: "Codeplayer", age:18};
var proxy = $.proxy (foo, obj, 5);
The agent invokes the Foo () function, at which point the inside of it points to object obj
proxy ();
Codeplayer
//
Run code
Unwrap ()
This function will move out of the element's parent element. This can quickly undo the effect of the. Wrap () method. Matching elements (and their sibling elements) will replace their parent elements on the DOM structure.
eg
Wrap each paragraph with a div with id "content"
# HTML Code:
<div>
<p>Hello</p>
<p>cruel</p>
<p>world</ p>
</div>
# jQuery code:
$ ("P"). Unwrap ()
Results:
<p>Hello</p>
<p>cruel</p>
<p>World</p>