Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
Javascript 在Pikaday插件中返回所选日期,在插件中?_Javascript_Pikaday - Fatal编程技术网

Javascript 在Pikaday插件中返回所选日期,在插件中?

Javascript 在Pikaday插件中返回所选日期,在插件中?,javascript,pikaday,Javascript,Pikaday,我想修改JavaScript(无JQuery)日期选择器,以便在日历上方的标题区域中显示所选日期 为此,我创建了一个新函数来呈现HTML标题区域: renderHeading = function(instance, c, year, month, days) { var opts = instance._o; var html = '<div class="pika-heading">'; html += '<h3 class=

我想修改JavaScript(无JQuery)日期选择器,以便在日历上方的标题区域中显示所选日期

为此,我创建了一个新函数来呈现HTML标题区域:

renderHeading = function(instance, c, year, month, days)
{
        var opts = instance._o;
        var html = '<div class="pika-heading">';
        html += '<h3 class="pika-heading-year">' + year + '</h3>';
        html += '<h1 class="pika-heading-date">' + opts.i18n.weekdaysShort[day] + ', ' + opts.i18n.monthsShort[month] + '</h1>';
        return html += '</div>';
},
在getDate函数中,并在my HTML render函数中返回,但这只在单击两次后才起作用,而且看起来很混乱


有人知道在插件的一部分中返回日期字符串的正确方法吗?

好的,我发现使用以下方法可以得到它:

instance.getDate()
从那里,我可以使用的方法来获得我需要的信息,例如:

var dayOfWeek = instance.getDate().getDay();
我的完整代码:

 renderHeading = function(instance, c, year, month, days)
 {

    var dayOfMonth = instance.getDate().getDate(),
    dayOfWeek = instance.getDate().getDay(),
    opts = instance._o,
    html = '<div class="pika-heading">';
    html += '<h3 class="pika-heading-year">' + year + '</h3>';
    html += '<h1 class="pika-heading-date">' + opts.i18n.weekdaysShort[dayOfWeek] + ', ' + dayOfMonth +', ' + opts.i18n.monthsShort[month] + '</h1>';
    return html += '</div>';
 },
renderHeading=function(实例、c、年、月、日)
{
var dayOfMonth=instance.getDate().getDate(),
dayOfWeek=instance.getDate().getDay(),
opts=实例,
html='';
html+=''年+'';
html+=''+opts.i18n.weekdaysShort[dayOfWeek]+'、'+dayOfMonth+'、'+opts.i18n.MonthShort[month]+'';
返回html+='';
},

好的,我发现使用以下方法可以得到它:

instance.getDate()
从那里,我可以使用的方法来获得我需要的信息,例如:

var dayOfWeek = instance.getDate().getDay();
我的完整代码:

 renderHeading = function(instance, c, year, month, days)
 {

    var dayOfMonth = instance.getDate().getDate(),
    dayOfWeek = instance.getDate().getDay(),
    opts = instance._o,
    html = '<div class="pika-heading">';
    html += '<h3 class="pika-heading-year">' + year + '</h3>';
    html += '<h1 class="pika-heading-date">' + opts.i18n.weekdaysShort[dayOfWeek] + ', ' + dayOfMonth +', ' + opts.i18n.monthsShort[month] + '</h1>';
    return html += '</div>';
 },
renderHeading=function(实例、c、年、月、日)
{
var dayOfMonth=instance.getDate().getDate(),
dayOfWeek=instance.getDate().getDay(),
opts=实例,
html='';
html+=''年+'';
html+=''+opts.i18n.weekdaysShort[dayOfWeek]+'、'+dayOfMonth+'、'+opts.i18n.MonthShort[month]+'';
返回html+='';
},