如何将关闭文本添加到datetimepicker引导程序? [英] How to add close text to datetimepicker bootstrap?

查看:88
本文介绍了如何将关闭文本添加到datetimepicker引导程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我想在其上添加封闭文字.默认情况下,它显示为"X",但我想更改它.有可能吗?

I want to add close text to it. by default it shows 'X', but I want to change it. Is it possible?

推荐答案

您可以使用 icons 选项为图标定义自定义CSS类,然后您可以编写CSS规则以自定义关闭文本,如下所示:

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>

这篇关于如何将关闭文本添加到datetimepicker引导程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆