Fullcalendar 2.4 悬停演示(非角度)https://jsfiddle.net/4kbLa4da/
$('#calendar').fullCalendar({
defaultDate: '2016-03-01',
events: [{
start: '2016-03-01',
end: '2016-03-05',
title: 'Event 1'
}, {
start: '2016-03-06',
end: '2016-03-15',
title: 'Event 2',
id: 3
}],
eventRender: function(event, element, view) {
// event._id gets auto-populated, either event.id or auto-generated value
element.attr('data-id', event._id);
toggleClass(event._id);
},
eventMouseover: function(event, jsEvent, view) {
toggleClass(event._id);
},
eventMouseout: function(event, jsEvent, view) {
toggleClass(event._id);
}
});
function toggleClass(id) {
/* Find all segments for the specific event and toggle a class */
var $event = $('a.fc-event[data-id="' + id + '"]');
$.each($event, function() {
$(this).toggleClass('my-highlight');
});
}
如果你想在事件点击:https ://jsfiddle.net/4kbLa4da/2/
eventClick: function (event, jsEvent, view) {
toggleClass(event._id);
}
/* ... */
/* And change toggleClass to turn it off first */
function toggleClass(id) {
/* Find all segments for the specific event and toggle a class */
var $event = $('a.fc-event[data-id="' + id + '"]');
$('a.my-highlight').each(function () {
$(this).toggleClass('my-highlight');
});
$.each($event, function() {
$(this).toggleClass('my-highlight');
});
}