jQuery node del...LOGIN

jQuery node delete

Node deletion

Parent node.empty(): Delete all child nodes in the matching element set

Deleted node. remove([expr]): Remove all matching elements from the DOM

<!DOCTYPE html>
<html>
    <head>
        <title>php.cn</title>
        <meta charset="utf-8" />
        <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
        <script>
        function  f1(){
            //父元素删除内部全部子元素
            $("#big").empty();  
            //具体节点删除
            $("#small li:first,#gai").remove();
        }
        </script>
        <style type="text/css">
        div {width:300px; height:200px; background-color:pink;}
        </style>
    </head>
    <body>
        <ul id="big">
            <li>A</li>
            <li>B</li>
            <li id="guan">C</li>
        </ul>
        <ul id="small">
            <li>a</li>
            <li>b</li>
            <li id="gai">c</li>
        </ul>
        <input type="button" value="删除" onclick="f1()" />
    </body>
</html>


Next Section
<!DOCTYPE html> <html> <head> <title>php.cn</title> <meta charset="utf-8" /> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script> function f1(){ //父元素删除内部全部子元素 $("#big").empty(); //具体节点删除 $("#small li:first,#gai").remove(); } </script> <style type="text/css"> div {width:300px; height:200px; background-color:pink;} </style> </head> <body> <ul id="big"> <li>A</li> <li>B</li> <li id="guan">C</li> </ul> <ul id="small"> <li>a</li> <li>b</li> <li id="gai">c</li> </ul> <input type="button" value="删除" onclick="f1()" /> </body> </html>
submitReset Code
ChapterCourseware