Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
Jquery 日期选择器在一个日期中显示日期,在另一个日期中隐藏日期_Jquery_Jquery Ui - Fatal编程技术网

Jquery 日期选择器在一个日期中显示日期,在另一个日期中隐藏日期

Jquery 日期选择器在一个日期中显示日期,在另一个日期中隐藏日期,jquery,jquery-ui,Jquery,Jquery Ui,我在我的页面中使用了两个日期选择器。一个日期选择器应显示日期、月份和年份, 另一个应该只显示月份和年份 我试过以下几种方法。 我尝试过更改css。 .ui-datepicker-calendar { display: none; } 但这会影响两个日期选择器 我曾尝试调用onClick函数。 $('.month-picker').click(function(){ $('.ui-datepicker-calendar').css('display','none'); });

我在我的页面中使用了两个日期选择器。一个日期选择器应显示日期、月份和年份, 另一个应该只显示月份和年份

我试过以下几种方法。 我尝试过更改css。

.ui-datepicker-calendar {
    display: none;
}
但这会影响两个日期选择器

我曾尝试调用onClick函数。

$('.month-picker').click(function(){
    $('.ui-datepicker-calendar').css('display','none');
});
当此函数隐藏ui datepicker日历类时,将显示ui datepicker标头和输入框之间的间隙

请帮我解决这个问题。先谢谢你


也被添加了

明白了!!经过几次尝试和错误,我想我找到了解决办法。像这样添加一个click事件处理程序

$('.month-picker').on('click', function() {
    $('.ui-datepicker-calendar').hide();    
});
然而,它仍然需要雕刻


签入

明白!!经过几次尝试和错误,我想我找到了解决办法。像这样添加一个click事件处理程序

$('.month-picker').on('click', function() {
    $('.ui-datepicker-calendar').hide();    
});
然而,它仍然需要雕刻


中检查它,尝试以下方法:

$(function() {
$('.date-picker').datepicker( {
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: 'MM yy',
    onClose: function(dateText, inst) { 
        var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
        var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
        $(this).datepicker('setDate', new Date(year, month, 1));
    }
});
}))

这是同样的理由

编辑

.ui-datepicker-calendar {
    display: none;
}

修正为自定义系统。请立即检查。请尝试以下方法:

$(function() {
$('.date-picker').datepicker( {
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: 'MM yy',
    onClose: function(dateText, inst) { 
        var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
        var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
        $(this).datepicker('setDate', new Date(year, month, 1));
    }
});
}))

这是同样的理由

编辑

.ui-datepicker-calendar {
    display: none;
}
修正为自定义系统。请立即检查。您可以这样做

$(".date-picker").datepicker({
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'MM yy',
        onClose: function (dateText, inst) {
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
            $(".ui-datepicker-calendar").hide();
        },
        beforeShow: function (dateText, inst) { $('.ui-datepicker-calendar').hide(); },
        onSelect: function (dateText, inst) { $(".ui-datepicker-calendar").hide(); }
    });

 add withoutDay class to input elements and add below jquery

 $(".withoutDay").focus(function () {
        $(".ui-datepicker-calendar").hide();
    });
你可以这样做

$(".date-picker").datepicker({
        changeMonth: true,
        changeYear: true,
        showButtonPanel: true,
        dateFormat: 'MM yy',
        onClose: function (dateText, inst) {
            var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
            var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
            $(this).datepicker('setDate', new Date(year, month, 1));
            $(".ui-datepicker-calendar").hide();
        },
        beforeShow: function (dateText, inst) { $('.ui-datepicker-calendar').hide(); },
        onSelect: function (dateText, inst) { $(".ui-datepicker-calendar").hide(); }
    });

 add withoutDay class to input elements and add below jquery

 $(".withoutDay").focus(function () {
        $(".ui-datepicker-calendar").hide();
    });

请在问题中加入代码。你看这个问题毫无意义吗?你到底想干什么!你到底需要做什么?你的问题并不清楚。你想做什么?我想Eugine想要第二个只显示月份和年份的选择器。他不希望显示日期,因为他对日期选择不感兴趣。只有一个月和一年。请在您的问题中包含代码。你看这个问题毫无意义吗?你到底想干什么!你到底需要做什么?你的问题并不清楚。你想做什么?我想Eugine想要第二个只显示月份和年份的选择器。他不希望显示日期,因为他对日期选择不感兴趣。只有一个月和一年。@Eugine Joseph检查我的更新答案并分享您的想法。谢谢朋友,它正在工作,但当单击datepicker标题下方时,days表会显示一秒钟。还有什么可以改变的吗?@Eugine Joseph检查我更新的答案并分享您的想法。谢谢朋友,它正在工作,但当单击日期选择器标题下方时,日期表会显示一秒钟。我有两个日期选择器,一个有天,另一个没有天。添加样式将影响两个日期选择器。我有两个日期选择器,一个有天,另一个没有天。添加样式将影响两个日期选择器。