remove()
功能
将匹配元素集合从DOM中删除。
语法
noder.remove(node)
参数
- node
HTMLElement对象,指定对象HTML元素节点
范例
Example: 将选中段落从DOM删除。
<!DOCTYPE html> <html> <head> <style> p { background:yellow; margin:6px 0; } </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> <p>Hello</p> how are <p>you?</p> <button>Call remove() on paragraphs</button> <script> require(["skylark/query", "skylark/finder", "skylark/noder"], function(query, finder, noder) { query("button").on("click",function(){ noder.remove(finder.find("p")); }); }); </script> </body> </html>