jquery unwrap() method


  Translation results:

unwrap

UK [ʌnˈræp] US [ʌnˈræp]

vt.Open; spread out

jquery unwrap() methodsyntax

Function: The unwrap() method deletes the parent element of the selected element.

Syntax: $(selector).unwrap()

jquery unwrap() methodexample

<!DOCTYPE html>
<html>
<head>
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").unwrap();
  });
});
</script>
<style type="text/css">
div{background-color:yellow;}
article{background-color:pink;}
</style>
</head>
<body>
<div>
<p>这是 div 元素中的段落。</p>
</div>
<article>
<p>这是 article 元素中的段落。</p>
</article>
<button>删除每个 p 元素的父元素</button>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A