Datepicker点击事件getdate

Datepicker click event getdate

我正在使用 bootstrap datepicker, and I want to triger click event to redirect to events page of the clicked date, I read the documentation of the datepicker for events, but there no click event, but it used changeDate and when I click on any date, I got that date and everything works fine, but when I click on any active date, I got random active date or repeat the last date.. how could I get clicked date even is that date is active ? fiddle

已更新 Fiddle

试试这个,

$('div').datepicker({
    multidate: false,


});

演示:http://jsfiddle.net/UI_Designer/2L1ovhbm/2/

就用这个可能是你想要的

$('div').on('changeDate', function(e){
  // extra 
  sdate = e.date.getDate() +'/'+ (e.date.getMonth()+1) + '/' + e.date.getFullYear();
  var getdate = $('p').html(sdate);  
  window.location.href = 'events.html?date='+getdate;
});
$('div').datepicker({
    multidate: false,
    todayHighlight: true,
    todayBtn: true
});

以上代码有效 fine.only 打印所选日期。

好的,我尝试了很多,但没有理想的解决方案,但我尝试在 JSfiddle

中添加这样的点击触发器
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
$('.datepicker-days').on('click', 'td.day', function (e) {
    e.preventDefault();
    var dat = $(this).text();
    var monthyear = $(this).closest('table').find('.datepicker-switch').text().split(" ");
    var monthalpha = monthyear[0];
    var monthnum;
    console.log(months.indexOf(monthalpha));
    var year = monthyear[1];
    if($(this).hasClass('old')){
        monthnum = (months.indexOf(monthalpha));
    } else if($(this).hasClass('new')){
        monthnum = (months.indexOf(monthalpha)+2);
    } else {
        monthnum = (months.indexOf(monthalpha)+1);
    }
    if(monthnum > 12){
        monthnum = 1;
    } else if (monthnum < 1){
        monthnum = 12;
    }
    $('p').html(dat+"/"+monthnum+"/"+year);
});