# dayClick

> FullCalendar v3 documentation, for an old release. Web version: https://legacy.fullcalendar.io/v3/dayClick
>
> Latest version (v7): https://fullcalendar.io/docs/dateClick.md

Triggered when the user clicks on a date or a time.

<div class='spec' markdown='1'>
function( *date*, *jsEvent*, *view*, [ *resourceObj* ] ) { }
</div>

`date` holds a [Moment](https://legacy.fullcalendar.io/v3/moment.md) for the clicked day. If an all-day area has been clicked, the moment will be [ambiguously-timed](https://legacy.fullcalendar.io/v3/moment.md#ambiguously-timed). If a slot in the agendaWeek or agendaDay views has been clicked, `date` will have the slot's time.

`jsEvent` holds the jQuery event with low-level information such as click coordinates.

`view` is set to the current [View Object](https://legacy.fullcalendar.io/v3/view-object.md).

Within the callback function, `this` is set to the `<td>` of the clicked day.

Here is an example that demonstrates all of these variables:

```js
$('#calendar').fullCalendar({
  dayClick: function(date, jsEvent, view) {

    alert('Clicked on: ' + date.format());

    alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);

    alert('Current view: ' + view.name);

    // change the day's background color just for fun
    $(this).css('background-color', 'red');

  }
});
```

## The `resourceObj` parameter

Since the introduction of the [Scheduler plugin](https://legacy.fullcalendar.io/v3/scheduler.md), this callback reports a [Resource Object](https://legacy.fullcalendar.io/v3/resource-object.md) parameter if the click happened on a resource. [More information](https://legacy.fullcalendar.io/v3/dayClick.md).


## List View

The dayClick trigger is **not** fired when the user clicks a day heading in list view.


## Resource Views

For resource views, this callback will receive an additional [Resource Object](https://legacy.fullcalendar.io/v3/resource-object.md) parameter. Example:

```js
$('#calendar').fullCalendar({
  dayClick: function(date, jsEvent, view, resourceObj) {

    alert('Date: ' + date.format());
    alert('Resource ID: ' + resourceObj.id);

  }
});
```

This is only available with the [Scheduler plugin](https://fullcalendar.io/pricing).

[See a demo of dayClick with resources](https://legacy.fullcalendar.io/v3/date-clicking-selecting-resource-demo).
