要使用哪种javascript日期选择器插件/库以获得最大的灵活性

Which javascript datepicker plugin/library to use for maximum flexibility

本文关键字:灵活性 插件 javascript 选择器 日期      更新时间:2023-09-26

我知道通用的javascript日期选择器很多,但它们看起来都不起眼。即使是jQuery UI日期选择器看起来也有点过时。我现在可以使用一个看起来粗糙的,但以后我们会想改进它的外观(使它与UI的其他部分更加一致),我不想因为选择一个很难改变的而自食其果。我说的只是装饰性的CSS/HTML更改(或模板化)

从模板灵活性的角度来看,你会推荐哪个日期/日历JavaScript插件?

谢谢,

我一直觉得jQuery UI日期选择器很棒。jQuery UI有很多主题,或者你可以自己滚动。如果你花时间让它看起来像你想要的那样,它肯定不会过时

使用Jquery UI,http://jqueryui.com/demos/datepicker/

这样你就不必再放任何库了。它几乎具备了您所需的所有功能以及良好的文档。参见下方的示例

$(document).ready(function){

    // the jquery calendar
    $( "#yourId" ).datepicker({
        showOn: "both", // show on clicking image as well as text box
        yearRange: "2000:2030",
        buttonImage: imagePath+"/b-calendar.gif", // custom image
        buttonImageOnly: true,
        dateFormat: 'dd-M-yy',
        showOtherMonths: true,
        selectOtherMonths: true
        ,changeMonth: true
        ,changeYear: true
        //,showAnim:"slideDown"
        ,buttonText: 'Show Calendar'
        //,showButtonPanel : true
        ,prevText: 'Previous Month'
        ,nextText: 'Next Month'
        ,beforeShow: function (textbox, instance) { // work around 4 alignment 
            instance.dpDiv.css({
                    marginTop: (-textbox.offsetHeight) + 'px',
                    marginLeft: textbox.offsetWidth + 30+ 'px'
        });
        }
    });
});