zoukankan      html  css  js  c++  java
  • jquery表格展示

      用bootstrap设计一个弹框,然后在弹框里面生成表格

    <html>
    <head>
        <link rel="stylesheet" href="./lib/bootstrap-4.0.0/dist/css/bootstrap.min.css" type="text/css"/>
        <script type="text/javascript" src="./lib/jquery/jquery-3.3.1.min.js"></script>
        <script type="text/javascript" src="./lib/bootstrap-4.0.0/dist/js/bootstrap.min.js"></script>
    </head>
    <body>
    <div id="test">
        <button id="button" class="btn btn-default" style="margin-left: 100px; margin-top: 100px;">click me to show</button>
        <!-- Modal -->
        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
             aria-hidden="true">
            <div class="modal-dialog modal-md" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        add body content here
                        <table class="table">
                            <tbody id="t-body">
                            </tbody>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            $("#button").click(function () {
                $('#exampleModal').modal('show');
                $('#t-body').empty();
                var $r1 = $('<tr></tr>');
                $r1.append($('<td>1</td>'));
                $r1.append($('<td>2</td>'));
                $('#t-body').append($r1);
                var $r2 = $('<tr></tr>');
                $r2.append($('<td>1</td>'));
                $r2.append($('<td>2</td>'));
                $('#t-body').append($r2);
            });
        });
    </script>
    </body>
    </html>
    var $r1 = $('<tr></tr>');就是生成一个元素,append就是当成子元素并附加在后面。
  • 相关阅读:
    基于WINCE6.0+S3C2443的camera驱动
    WINCE下基于SL031的RFID功能的实现
    WINCE6.0+S3C2443下的activesync问题
    WINCE6.0+S3C2443下WatchDog学习
    错误的抉择,痛悔
    WINCE5.0下SQL server compact版本更新
    做生意和打工的区别
    WINCE基于MC8630的3G模块的控制和加载
    Xml Tips
    VB.NET and C# Comparison
  • 原文地址:https://www.cnblogs.com/chenmz1995/p/10224433.html
Copyright © 2011-2022 走看看