Home > Web Front-end > JS Tutorial > body text

Example of usage of unwrap() method in jQuery

巴扎黑
Release: 2017-06-24 13:51:23
Original
1501 people have browsed it

This article mainly introduces the usage of the unwrap() method in jQuery. It analyzes the definition and function of the unwrap() method and the usage skills of removing the parent element of the matching element. Friends who need it can refer to it. Next

The example in this article describes the usage of the unwrap() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

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

From the literal meaning of the method, we can see that it is the effect of clearing the wrap() method.

Syntax:

The code is as follows:

$(selector).unwrap()

Example 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="http://www.jb51.net/" />
<
head
>
<title>脚本之家</title>
<style type="text/css">
    p
    {
        
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>
</head>
<body>
    <p>
       <p>我是p元素</p>
    </p>
    <button>用p包裹每个段落</button>
</body>
</html>
Copy after login

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

The above is the detailed content of Example of usage of unwrap() method in jQuery. 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