$(" #txtStartDate")。datepicker({})对我不起作用

时间:2018-04-05 15:16:58

标签: jquery datepicker jquerydatetimepicker

  <div class="datePickerContainer">
                            <input class="form-control datepicker bg-color-white" placeholder="MM/DD/YYYY" maxlength="15" ng-model="PriceLineObj.StartDate" id="txtDate" type="text">
                        </div>

,JQuery代码是:

  $(function () {

    debugger;

    $("#txtDate").datepicker({
        showOn: "button",
        class: "tester",
        buttonImage: "images/calendar-green.gif",
        buttonImageOnly: true,
        buttonText: "Select date",
        minDate: 0,
        maxDate: 365,
        beforeShow: function () {
            $('#ui-datepicker-div').addClass("lbAvalabilityDatePicker")
        },
        onSelect: function (selectedDate) {
            $('.enddatepicker').datepicker('option', 'minDate', selectedDate);
        }
    });
})

现在,当我点击images / calendar-green.gif时,我无法看到日历。我已经添加了所需的库。请建议

1 个答案:

答案 0 :(得分:1)

单击选择日期时可以使用

&#13;
&#13;
$(function() {
  debugger;
  $("#txtDate").datepicker({
    showOn: "button",
    class: "tester",
    buttonImage: "images/calendar-green.gif",
    buttonImageOnly: true,
    buttonText: "Select date",
    minDate: 0,
    maxDate: 365,
    beforeShow: function() {
      $('#ui-datepicker-div').addClass("lbAvalabilityDatePicker")
    },
    onSelect: function(selectedDate) {
      $('.enddatepicker').datepicker('option', 'minDate', selectedDate);
    }
  });
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<div class="datePickerContainer">
  <input class="form-control datepicker bg-color-white" placeholder="MM/DD/YYYY" maxlength="15" ng-model="PriceLineObj.StartDate" id="txtDate" type="text">
</div>
&#13;
&#13;
&#13;