jQuery任务列表案例

jQuery任务列表案例

在这里插入图片描述


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>任务列表</title>
    <link rel="stylesheet" href="./layui/css/layui.css">
    <!-- Bootstrap CSS -->
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.3/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

    <style type="text/css">
        .Div {
            border: 3px ridge rgba(37, 34, 34, 0.605);
            margin: 0 auto;
            text-align: center;
            width: 750px;
            height: 1000px;
            border-style: dotted solid double dashed;

        }

        h5 {
            text-align: center;
            margin-bottom: 30px;
            font-weight: bold;
        }

        p {
            font-size: 20px;

        }

        .input-group {
            margin: 0 auto;
        }

        #exampleInputAmount {
            margin-right: 15px;
            width: 460px;
        }

        #thead1 tr th {
            font-weight: bold;
            text-align: center;
        }
    </style>


</head>

<body>
    <!-- jQuery -->
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!-- Bootstrap JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="./layui/layui.js"></script>
    <!-- 你的 HTML 代码 -->
    <script>
        //获取当前年月日几点几分几秒星期几并打印
        function getTimer() {
            var date = new Date()
            var week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
            var year = date.getFullYear()
            var month = date.getMonth() + 1
            var datee = date.getDate()
            var day = date.getDay()
            var time = year + '年' + month + '月' + datee + '日 ';
            function getTimerr() {
                var time = new Date()
                var hour = time.getHours()
                hour = hour < 10 ? '0' + hour : hour
                var minute = time.getMinutes()
                minute = minute < 10 ? '0' + minute : minute
                var second = time.getSeconds()
                second = second < 10 ? '0' + second : second
                return hour + ':' + minute + ':' + second
            }
            return time + ' ' + getTimerr()+ ' ' +week[day]
        }

        function ad(params) {
            var ss = $(params).prev().val()
            var ti = getTimer()
            
            var v = $('<tr>' +
                ' <td class="col">'+ss+'</td>' +
                ' <td class="col">'+ti+'</td> ' +
                '<td> ' +
                ' <div> ' +
                '        <button type="button" class="btn btn-default" οnclick="sb(this)">button</button> ' +
                '       <button οnclick="rm(this)" type="button" class="btn btn-default">delete</button> ' +
                '  </div> ' +
                '</td> ' +
                '</tr>)');
            $('.layui-table tbody').prepend(v)
            $(params).prev().val('');
        }
        function rm(params) {
          $(params).parent().parent().parent().remove();
          
        }
        function sb(params) {
            $(params).parent().parent().parent().children('.col').css({color:'rgb(255, 25, 25)','text-decoration': 'line-through'});
        }
    </script> 
    <div class="Div">
        <p><b>任务列表</b></p>

        <div class="input-group">
            <input type="text" class="btn btn-default" id="exampleInputAmount" placeholder="输入要添加的任务" >
            <button type="button" class="btn btn-info" id="btn1" onclick="ad(this)">add</button>
        </div>

        <div>
            <table class="layui-table" lay-even lay-skin="line" lay-size="lg">
                <colgroup>
                    <col width="150">
                    <col>
                </colgroup>
                <thead id="thead1">
                    <tr>
                        <th>任务</th>
                        <th>时间</th>
                        <th>选择</th>
                        
                    </tr>
                </thead>
                <tbody>
                    <!-- <tr>
                        <td class="col">敲代码</td>
                        <td class="col">Data</td>
                        <td>
                            <div>

                                <button type="button" class="btn btn-default" οnclick="sb(this)">button</button>

                                <button type="button" class="btn btn-default" οnclick="rm(this)">delete</button>


                            </div>
                        </td>
                    </tr> -->
                </tbody>
            </table>
        </div>

    </div>
</body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值