JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.4.0/fullcalendar.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.4.0/fullcalendar.js"></script>
<div id='calendar'>
</div>
CSS
.my-highlight {
color: black !important;
background-color: lightblue !important;
}
JavaScript
$('#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');
});
}