Jquery日历弹出颜色变化

时间:2018-03-14 03:27:27

标签: javascript jquery html jquery-ui

我正在使用jquery创建一个日期选择器。我在更改弹出日历的颜色时遇到问题。 我的代码是:

def entropy(hist, bit_instead_of_nat=False):
    """
    given a list of positive values as a histogram drawn from any information source,
    returns the entropy of its probability density function. Usage example:
      hist = [513, 487] # we tossed a coin 1000 times and this is our histogram
      print entropy(hist, True)  # The result is approximately 1 bit
      hist = [-1, 10, 10]; hist = [0] # this kind of things will trigger the warning
    """
    h = np.asarray(hist, dtype=np.float64)
    if h.sum()<=0 or (h<0).any():
        print "[entropy] WARNING, malformed/empty input %s. Returning None."%str(hist)
        return None
    h = h/h.sum()
    log_fn = np.ma.log2 if bit_instead_of_nat else np.ma.log
    return -(h*log_fn(h)).sum()

而html是:

 $(function() {
    $( "#checkin" ).datepicker({minDate : 0, dateFormat: 'dd-mm-yy'});
    $("#checkin").addClass("my-class");
    $("#checkout").attr("disabled", "disabled");
    $( "#checkout" ).datepicker({minDate:0, dateFormat: 'dd-mm-yy'});

    $( "#checkin" ).on("change",function(){
        onCheckin();

    });

});

function onCheckin(){
    if($("#checkin").val() !== ""){
        $("#checkout").removeAttr("disabled");
        var dateMin = $('#checkin').datepicker("getDate");
        var rMin = new Date(dateMin.getFullYear(), dateMin.getMonth(), dateMin.getDate() + 1);
        $("#checkout").datepicker('option', 'minDate', new Date(rMin));
    }else{
        $("#checkout").val("");
        $("#checkout").attr("disabled", "disabled");
    }
}

Css是:

<div class='row'>
    <div class='col-4'>
    <p>Checkin: <input type='text' id='checkin' ></p><br>
    </div>
    <div class='col-4'>
    <p>Checkout: <input type='text' id='checkout'>
    </div>
</div>

它改变了文本区域的颜色,但是我想在日历弹出时给出刚性背景。我是Web开发的新手。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

日历弹出式按住课程ui-datepicker。所以请尝试以下css:

.ui-datepicker {
  background-color: #FF0F0F !important;
 }

OR:

$('.ui-datepicker').addClass('my-class');

你的班级是:

.my-class{
  background-color: #FF0F0F !important;
 }

工作代码段。

&#13;
&#13;
$('#date').datepicker();
$('.ui-datepicker').addClass('my-class');
&#13;
.my-class{
    background-color: #FF0F0F !important;
}
&#13;
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<input type='text' id='date'/>
&#13;
&#13;
&#13;