Unwrap () method usage example in jquery

Source: Internet
Author: User

This article mainly introduced jquery Unwrap () method usage, the example analysis unwrap () method definition, the function and removes the matching element parent element The use skill, needs the friend to be possible to refer to under

-->

This example describes the use of the unwrap () method in jquery. Share to everyone for your reference. The specific analysis is as follows:

This method will remove the parent element of the matching element.

The effect of clearing the wrap () method can be seen from the literal meaning of the method.

Grammar:

The code is as follows: $ (selector). Unwrap ()
Instance code:

The code is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<meta name= "Author" content= "http://www.jb51.net/"/>
<title> Script House </title>
<style type= "Text/css" >
Div
{
width:200px;
height:200px;
BORDER:1PX solid blue;
}
P
{
width:150px;
height:150px;
border:1px solid red;
}
</style>
<script type= "Text/javascript" src= "Jquery/1.4.4/jquery.min.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("button"). Click (function () {
$ ("P"). Unwrap ();
});
});
</script>
<body>
<div>
<p> I am P element </p>
</div>
<button> use div to wrap each paragraph </button>
</body>

The above code can remove the parent element of the P element.

I hope this article will help you with your jquery programming.

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.