Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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 - Fatal编程技术网

JQuery日期选择器选择年份

JQuery日期选择器选择年份,jquery,Jquery,我希望用户能够选择年份,而不必单击与月份相关的上一个或下一个选项卡。我怎样才能做到这一点。以下是我目前的代码: if ( $('[type="date"]').prop('type') != 'date' ) { $('[type="date"]').datepicker({ //Something here }); } 这是我的datepiker配置,我使用的是字体很棒的图标,所以我可以忽略它。你想要的是changeyear参数 $('#elementID').datepi

我希望用户能够选择年份,而不必单击与月份相关的上一个或下一个选项卡。我怎样才能做到这一点。以下是我目前的代码:

if ( $('[type="date"]').prop('type') != 'date' ) {
    $('[type="date"]').datepicker({
    //Something here

});
}

这是我的datepiker配置,我使用的是字体很棒的图标,所以我可以忽略它。你想要的是changeyear参数

$('#elementID').datepicker({ 
    showOn: 'both',
    buttonText: "<i class='fa fa-calendar fa-lg blue'></i>",
    changeMonth: true,
    changeYear: true
});
$('#elementID')。日期选择器({
showOn:“两者都有”,
按钮文本:“”,
变化月:对,
变化年:对
});

这很完美,但为什么月份和年份的选择如此广泛?它们似乎占据了整行。您可以执行f12并找出它们的css类,然后尝试覆盖width属性。year类似乎是ui datepicker year。这取决于你来决定投资回报是否值得。祝你好运