我正在开发一个项目,需要我根据所选选项做三件事。下拉列表中的选项有每日、每周、每月和每年。
If Weekly is chosen, I just need the days of the week to be displayed as buttons.
If Monthly is chosen, I just need the dates (1-31) to be displayed as buttons.
If Yearly is chosen, I just need the months of the year to be displayed as buttons.
我可以在 datepicker 或 angularJS 中使用选项(我还在学习 angularJS)来让它工作吗?
请注意,一旦我从下拉列表中选择了该选项,我会更喜欢将按钮填充到我指定的 div 中(这意味着,我不会单击输入框来显示日历)。
如果有 datepicker 或 calendarUI 的替代方案,我也愿意尝试。请在这件事上给予我帮助。预先感谢您的所有建议。
最佳答案
你可以尝试这样的东西(Fiddle demo):
var days = ['Mon','Tues','Wed','Thu','Fri','Sat','Sun'];
function getContent(dateScope)
{
var ret = "";
switch(dateScope) {
case "w": for(i in days)
ret += "<button>"+days[i]+"</button>";
break;
case "m": for(i=1;i<=31;i++)
ret += "<button>"+i+"</button>";
break;
case "y": for(i=1;i<=12;i++)
ret += "<button>"+i+"</button>";
break;
}
return ret;
}
$("#dateScope").change(function(){
$("#buttonsDiv").html(getContent($(this).val()));
});
关于javascript - 如何使用JQuery DatePicker或AngularJS单独显示星期几?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25048084/