从DOM中删除指定元素的父元素,将指定元素留在它们的位置。
noder.unwrap(node)
Example: 点击按钮,p 元素移出父级元素。
<!DOCTYPE html> <html> <head> <style> div { border: 2px solid blue;} p { background: yellow;margin: 4px;} </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [{ name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <button>unwrap</button> <div> <p>Hello</p> <p>World</p> </div> <script> require(["skylark/query", "skylark/finder", "skylark/noder"], function($, finder, noder) { var p = finder.find("p"); $("button").on("click", function() { noder.unwrap(p); }); }); </script> </body> </html>