Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery datepicker addclass()不工作_Javascript_Jquery_Datepicker - Fatal编程技术网

Javascript Jquery datepicker addclass()不工作

Javascript Jquery datepicker addclass()不工作,javascript,jquery,datepicker,Javascript,Jquery,Datepicker,我有一个jquery datepicker addClass方法没有在id为#ui datepicker div的div中添加类 Jquery代码: $(document).ready(function () { //this works $('.date-picker1').addClass("mtp"); //This does not work $("#ui-datepicker-div").addClass("myclassdoesn

我有一个jquery datepicker addClass方法没有在id为#ui datepicker div的div中添加类

Jquery代码:

$(document).ready(function () {

      //this works
     $('.date-picker1').addClass("mtp");
          //This does not work
     $("#ui-datepicker-div").addClass("myclassdoesntgo");
     $('.date-picker1').datepicker({
         changeMonth: true,
         changeYear: true,
         showButtonPanel: true,
         dateFormat: 'yy',
         onClose: function (dateText, inst) {
             var month = 1;
             // month= $("#ui-datepicker-div .ui-datepicker-month :selected").val();
             var year = 1900;
             year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
             $(this).datepicker('setDate', new Date(year, 25));
             // $("startDate").val = month;
             $("startMonth").val = year;
         }
     });
     $('#ui-datepicker-div').css('display', 'none');

 });

完整代码是

只需在调用datepicker方法后添加它:

 $(document).ready(function () {

            $('.date-picker1').addClass("mtp");

            $('.date-picker1').datepicker({
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true,
                dateFormat: 'yy',
                onClose: function (dateText, inst) {
                    var month = 1;
                    // month= $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                    var year = 1900;
                    year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                    $(this).datepicker('setDate', new Date(year, 25));
                    // $("startDate").val = month;
                    $("startMonth").val = year;
                }
            });
      $("#ui-datepicker-div").addClass("myclassdoesntgo");
      $('#ui-datepicker-div').css('display','none');

        }); 

这里的完整工作小提琴:

什么是
ui日期选择器div
?它是由日期选择器生成的id