本文介绍了Fullcalendar jquery插件在nextYear按钮上显示年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我使用fullcalendar jquery插件,并希望在nextYear和prevYear按钮中显示2009和2011年。 例如: 2009年5月2010 2011 我知道我可以在按钮上放置静态文本,如下所示: buttonText:{ prevYear:'2009', nextYear:'2011'}, 但我希望这些年份有所改变,具体取决于日历当前正在查看的年份。这里有关于年的文档: http://arshaw.com/fullcalendar/docs / current_date / ,但我不知道如何获得'year'属性。 任何示例都将被赞赏, 谢谢, Nate 解决方案与乔尔的答案类似,但更新为FullCalendar v1.6.4: var calendar = document.getElementById(...), $ calendar = $(calendar),//将日历一次包装 prevYearButton, nextYearButton; $ calendar.fullCalendar({ ... viewRender:function(){ var year = $ calendar.fullCalendar('getDate')。getFullYear( ); prevYearButton.innerHTML = year - 1; nextYearButton.innerHTML = year + 1; } }); //在初始化FullCalendar 后执行此操作prevYearButton = calendar.querySelector('。fc-button-prevYear'); nextYearButton = calendar.querySelector('。fc-button-nextYear'); I'm using the fullcalendar jquery plugin, and would like to display 2009 and 2011 in the nextYear and prevYear buttons.For exmaple:2009 May 2010 2011I know I can put static text on the buttons like this:buttonText: {prevYear: '2009',nextYear: '2011'},But I would like those years to change, depending on the year that the calendar is currently viewing. There's documentation about 'year' here:http://arshaw.com/fullcalendar/docs/current_date/ but I don't know how to get that 'year' property.Any examples would be appreciated,Thanks,--Nate 解决方案 Similar to Joel's answer, but updated for FullCalendar v1.6.4:var calendar = document.getElementById(...), $calendar = $(calendar ), // wrap calendar once prevYearButton, nextYearButton;$calendar.fullCalendar({ ... viewRender: function () { var year = $calendar.fullCalendar('getDate').getFullYear(); prevYearButton.innerHTML = year - 1; nextYearButton.innerHTML = year + 1; }});// do this after initializing FullCalendarprevYearButton = calendar.querySelector('.fc-button-prevYear');nextYearButton = calendar.querySelector('.fc-button-nextYear'); 这篇关于Fullcalendar jquery插件在nextYear按钮上显示年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 23:14