zoukankan      html  css  js  c++  java
  • jquery元素插入、删除、清空

    1)jquery元素插入

    位置1)表示元素前:$("#test").before(……);

    位置2)表示元素内前:$("#test").prepend(……);

    位置3)表示元素内后:$("#test").append(……);

    位置4)表示元素后:$("#test"). after(……);

    2)jquery元素删除(包括自身与所有文本和子节点)

    $("#test").remove();

    3)jquery元素清空(包括所有文本和子节点),不会删除元素属性

    $("#test").empty();

    代码如下:

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
        .contenter{
            border:1px solid #282828;
            width:600px;
            height:400px;
        }
    
        .child{
            width:90%;
            height:200px;
            border:1px solid red;
        }
    
        </style>
    </head>
    <body>
    <div class="contenter">
        <div class="child"></div>
    </div>
        <script type="text/javascript" src="2.1.js"></script>
        <script type="text/javascript">
         $(function(){
           $(".contenter").click(function(){
           // console.log("111111");
           // $(this).append()
           // $(this).before("111111");
            // $(this).after("22222");
            // $(this).append("333333");
            // $(this).prepend("4444444 
    
    ");
            // $(this).remove();
            // $(this).empty();
    
           });
    
         });
    
        </script>
    </body>
    </html>
  • 相关阅读:
    C#的访问修饰符
    C#的数据类型
    iOS--小结系列八(继续)
    ios--小结系列八 控制器管理
    ios--小结系列八 程序启动原理
    ios--小结系列七 通知机制
    ios--小结系列六继续-UITableViewCell
    ios--小结系列六
    ios--小结系列五
    ios--小结系列四
  • 原文地址:https://www.cnblogs.com/wuheng1991/p/5275474.html
Copyright © 2011-2022 走看看