Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.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-如果具有特定类,则显示周数_Javascript_Jquery_Jquery Ui_Datepicker_Jquery Ui Datepicker - Fatal编程技术网

Javascript jquery datepicker-如果具有特定类,则显示周数

Javascript jquery datepicker-如果具有特定类,则显示周数,javascript,jquery,jquery-ui,datepicker,jquery-ui-datepicker,Javascript,Jquery,Jquery Ui,Datepicker,Jquery Ui Datepicker,我正在使用jQueryUIDatePicker,但我只想在输入元素有特定类时显示周数 这是我尝试过的,但没有成功 $(".myCal").datepicker({ showWeek: function(dateText, inst) { $(this).hasClass("showWeek"); } }); 你能试试这个吗 $(".myCal").datepicker({ showWeek: $(this).hasClass("showWeek"); }); 作为状态,sho

我正在使用jQueryUIDatePicker,但我只想在输入元素有特定类时显示周数

这是我尝试过的,但没有成功

$(".myCal").datepicker({
    showWeek: function(dateText, inst) { $(this).hasClass("showWeek"); }
});
你能试试这个吗

$(".myCal").datepicker({
    showWeek: $(this).hasClass("showWeek");
});

作为状态,
showWeek
接受布尔值

使用类选择器时,每个方法都需要迭代所有匹配元素,然后使用$(this)


您的匿名函数中是否缺少“返回”项?您编辑的答案是的副本。没问题,只是为了公平竞争:)
$(".myCal").datepicker({
    showWeek: $(this).hasClass("showWeek");
});
$(".myCal").each(function () {
    $(this).datepicker({
        showWeek: $(this).hasClass('showWeek')
    });
});