首页 > web前端 > css教程 > 正文

bootstrap中关于时间控件

PHPz
发布: 2018-10-13 17:11:12
原创
2859 人浏览过

<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel = "stylesheet" type="text/css" href = "./assets/datetimepicker/css/bootstrap-datetimepicker.css" / >
<style>
    #ipt::after {
        content: "222";
        display: block;
        width: 5px;
        height: 8px;
        color: red;
        outline: none;
    }

    * {
        box-sizing: border-box;
    }

    #box {
        width: 600px;
        margin: 0 auto;
        padding: 35px;
    }

    #box2 {
        height: 350px;
        border: 1px solid #ccc;
        overflow-y: auto;
        padding: 30px;
    }

    #box2 p {
        margin: 0 auto;
        text-align: center;
    }

    #top_nav {
        position: fixed;
        top: 5px;
        left: 50%;
        width: 200px;
        margin-left: -100px;
    }

    input.datetimepicker {
        margin-top: 10px;
        outline: none;
        border: 1px solid #ccc;
    }
</style>
登录后复制
<p id="box">
    <p id="top_nav">娣诲姞鏃堕棿鎺т欢 <button type="button" id="btn2">娣诲姞</button></p>
    <p id="box2"></p>
</p>
<script src="https://cdn.bootcss.com/jquery/2.2.3/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<script type="text/javascript" src="./assets/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="./assets/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script>
    $(function () {
        var timeNum = 1;
        var addTime =
            &#39;<p class="time-p"><input type="text" value="2017-09-10" class="datetimepicker"><span>  閫夋嫨鏃堕棿</span></p>&#39;;
        $("#btn2").on("click", function () {
            var $addTime = $(addTime).children().attr("id", "time" + timeNum).end()
            $("#box2").append($addTime);
            activeTime(("#time" + timeNum));
            timeNum++;
        })

        function activeTime(tagid) {
            $(tagid).datetimepicker({
                format: &#39;yyyy-mm-dd&#39;,
                language: &#39;zh-CN&#39;,
                weekStart: 1,
                bootcssVer: 3,
                todayBtn: 1,
                autoclose: 1,
                todayHighlight: true,
                startView: 2,
                minView: 2,
                pickerPosition: &#39;bottom-right&#39;,
                forceParse: 0,
                keyboardNavigation: 1,
                forceParse: 1
            });
        }
        activeTime("#time1")
    })
</script>
登录后复制

【相关视频推荐:Bootstrap教程

以上是bootstrap中关于时间控件的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板