zoukankan      html  css  js  c++  java
  • jquery动态创建节点

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <style type="text/css">
    .textitem { background-color:Yellow;}
    </style>
    <script src="Scripts/jquery-1.4.2.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    // var link = $("<a href='http://www.baidu.com'>百度</a>");
    // $("div:first").append(link);
    });

    $(function () {
    var data = { "百度": "http://www.baidu.com", "新浪": "http://www.sina.com" };
    $.each(data, function (key, value) {
    var tr = $("<tr><td>" + key + "</td><td><a href=" + value + ">" + key + "</a></td></tr>");
    $("#tableSites").append(tr);
    });
    });

    $(function () {
    $("#removeUL").click(function () {
    $("ul li.textitem").remove();
    });
    });
    </script>
    </head>
    <body>
    <div>
    </div>

    <table id="tableSites">
    </table>

    <ul>
    <li>abc</li>
    <li class="textitem">def</li>
    <li>ghi</li>
    <li class="textitem">abc</li>
    <li>lmn</li>
    </ul>

    <input type="button" value="删除ul中的一部分" id="removeUL" />

    </body>
    </html>

  • 相关阅读:
    进程与线程(二) java进程的内存模型
    进程学习(一) 进程的地址空间
    在一个数组中除两个数字只出现1次外,其它数字都出现了2次
    倒水问题
    leecode 树是否是平衡树 java
    Max Sum
    Encoding
    海阔天空-
    Binomial Showdown
    Square
  • 原文地址:https://www.cnblogs.com/klsw/p/4715475.html
Copyright © 2011-2022 走看看