Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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 jQuery.eCalendar()-仅高亮显示onclick日期_Javascript_Jquery_Calendar - Fatal编程技术网

Javascript jQuery.eCalendar()-仅高亮显示onclick日期

Javascript jQuery.eCalendar()-仅高亮显示onclick日期,javascript,jquery,calendar,Javascript,Jquery,Calendar,我现在拥有的当前代码突出显示了我单击的每个日期。我只想突出显示特定的点击日期。如何才能正确地执行此操作?提前感谢您提供的任何帮助 var mouseClickEvent = function () { $(".c-event-item").hide(); var d = $(this).attr('data-event-day'); $('div.c-event[data-event-day="' + d + '"]').show(); $('div.c-even

我现在拥有的当前代码突出显示了我单击的每个日期。我只想突出显示特定的点击日期。如何才能正确地执行此操作?提前感谢您提供的任何帮助

var mouseClickEvent = function () {
    $(".c-event-item").hide();
    var d = $(this).attr('data-event-day');
    $('div.c-event[data-event-day="' + d + '"]').show();
    $('div.c-event[data-event-day="' + d + '"]').addClass('c-event-onclick');
    $('div.c-event-item[data-event-day="' + d + '"]').show();
};

下面是JSFIDLE:

您需要先删除
c-event-onclick
类,然后再添加它。因此,该代码应该可以工作:

var mouseClickEvent = function () {
    $(".c-event-item").hide();
    $(".c-event").removeClass('c-event-onclick'); // <== add this
    var d = $(this).attr('data-event-day');
    $('div.c-event[data-event-day="' + d + '"]').show();
    $('div.c-event[data-event-day="' + d + '"]').addClass('c-event-onclick');
    $('div.c-event-item[data-event-day="' + d + '"]').show();
};
var mouseClickEvent=函数(){
$(“.c-event-item”).hide();

$(“.c-event”).removeClass('c-event-onclick');//它工作起来很有魅力!但是为什么当我单击今天的日期时它不工作呢?您可能也想将c-event类添加到今天的日期。我不知道在今天的日期在哪里添加c-event-onclick。我尝试了$('div.c-today.c-event[data event day=“'+d+'”)。addClass('c-event-onclick'));但它不起作用。我的意思是将
c-event
类添加到DOM中的today单元格中。并且不需要在JS中进行任何更改。我已经在DOM中添加了
c-event
。单击它后,它应该会变为红色,但它仍然是蓝色的。