How to add close text to datetimepicker bootstrap?

前端 未结 2 1555
礼貌的吻别
礼貌的吻别 2020-12-11 22:09
$(function() {
    $(\'input.month-mode\').datetimepicker({
        viewMode: \'months\',
        format: \'MM/YYYY\',
        showClose: true,
        maxDate: curr         


        
相关标签:
2条回答
  • 2020-12-11 22:22

    You can use icons option to define a custom css class for your icon and then you can write a css rule to customize close text as shown below:

    $(function () {
        var current_month = moment(); // just a sample value
        $('#datetimepicker1').datetimepicker({
            showClose: true,
            viewMode: 'months',
            format: 'MM/YYYY',
            maxDate: current_month,
            icons: {
                close: 'closeText'
            }
        });
    });
    .closeText:before {
        content: "Close";
    }
    <link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet"/>
    <link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
    
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
    
    <div class='input-group date' id='datetimepicker1'>
      <input type='text' class="form-control" />
      <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
      </span>
    </div>

    0 讨论(0)
  • 2020-12-11 22:26

    One way to do this is to use the icon classes to a add a new class and then use css to add some content. Something like:

    $(function() {
            $('input.month-mode').datetimepicker({
                viewMode: 'months',
                format: 'MM/YYYY',
                showClose: true,
                maxDate: current_month,
                icons: {
                    close: 'textclass1'
                    }
            });
        });
    

    Css:

    .textclass1::before {
      content: "Close";
    }
    
    0 讨论(0)
提交回复
热议问题