尘风
红尘往事,一切随风

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="https://www.imooc.com/static/lib/jquery/1.9.1/jquery.js"></script>
    <style>
    .left,
    .right {
        width: 300px;
        height: 120px;
    }
   
    .left div,
    .right div {
        width: 100px;
        height: 90px;
        padding: 5px;
        margin: 5px;
        float: left;
        border: 1px solid #ccc;
    }
   
    .left div {
        background: #bbffaa;
    }
   
    .right div {
        background: yellow;
    }
    </style>
</head>

<body>
    <h2>动态创建元素节点</h2>
    <button>点击通过jQuery动态创建元素节点</button>
    <script type="text/javascript">
    $("button").on('click', function() {
       var a = $("body");
        var di=$("<div class='right'><div class='aaron'>动态创建DIV元素节点</div></div>")
        a.append(di)
    })
  </script>
  </body>
</html>

posted on 2020-09-07 23:44  一个行者  阅读(338)  评论(0编辑  收藏  举报