Bootstrap-Selectpicker:使不可点击的年份不可见并直接显示选定的给定年份
Bootstrap-Selectpicker: Make non-clickable years invisible and show directly given year as selected
以下代码块:
$(".datepicker").datepicker( {
format: ' yyyy', // Notice the Extra space at the beginning
viewMode: 'years',
minViewMode: 'years',
startDate: '-100y',
endDate: '-17y'
});
输出:
我有 2 个问题:
如何让不可点击的年份不可见?
如果用户在输入字段中键入年份然后单击此输入字段,则所选年份应显示为已标记。
这就是想要的结果:
目前正在学习the following API documentation,还没有找到相关的章节。有人能帮我吗?几年前我已经这样做了,但不幸的是我不记得是怎么做的了。
我浏览了 API 一点但没有找到这个功能,但是我创建了一个简单的解决方案:
http://jsfiddle.net/m7atu7up/6/
我们简单地使用CSS来隐藏有残疾人class的年份跨度。
.datepicker table tr td span.disabled {
display: none;
}
我们使用以下选择器来设置所选跨度的样式:
.datepicker table tr td span.active.active
这个 fiddle 对你的两个问题都有效。
以下代码块:
$(".datepicker").datepicker( {
format: ' yyyy', // Notice the Extra space at the beginning
viewMode: 'years',
minViewMode: 'years',
startDate: '-100y',
endDate: '-17y'
});
输出:
我有 2 个问题:
如何让不可点击的年份不可见?
如果用户在输入字段中键入年份然后单击此输入字段,则所选年份应显示为已标记。
这就是想要的结果:
目前正在学习the following API documentation,还没有找到相关的章节。有人能帮我吗?几年前我已经这样做了,但不幸的是我不记得是怎么做的了。
我浏览了 API 一点但没有找到这个功能,但是我创建了一个简单的解决方案:
http://jsfiddle.net/m7atu7up/6/
我们简单地使用CSS来隐藏有残疾人class的年份跨度。
.datepicker table tr td span.disabled {
display: none;
}
我们使用以下选择器来设置所选跨度的样式:
.datepicker table tr td span.active.active
这个 fiddle 对你的两个问题都有效。