zoukankan      html  css  js  c++  java
  • 动态创建内容

    html:

    <!DOCTYPE >
    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style type="text/css">
    * {
    margin: 10px;
    padding: 0;
    font-family: "微软雅黑", "arial", " sans-serif";
    }

    #div {
    200px;
    height: 200px;
    border: 1px red solid;
    }

    .test {
    background: #76DBA3;
    }
    </style>
    <script type="text/javascript" src="js/jquery-2.2.2.min.js">
    </script>

    <script type="text/javascript">
    $(function () {
    $("<div>", {
    text: "这是动态创建的页面元素",
    id: "div",
    click: function () {
    $(this).toggleClass("test");
    }
    }).appendTo("body");
    })
    </script>
    </head>

    <body>

    </body>

    </html>

    result:

    运行:

  • 相关阅读:
    lucene1.0.1写入分析
    esm数据迁移
    datadog入门
    elasticsearch datehistogram聚合
    cookie实战
    泛型编程
    lucene分析
    2020年12月阅读文章
    迭代
    lucene搜索
  • 原文地址:https://www.cnblogs.com/theWayToAce/p/5495658.html
Copyright © 2011-2022 走看看