I am using jQuery UI Datepicker. How can I add a class to the element on click event.
Below is my code. What am I doing wrong?
$(function(){
$('#calendar').datepicker();
$('#calendar').children('td').click(function(){
$(this).addClass('selected');
});
});
Here’s a quick solution that should get you started, anyway:
The
beforeShowDayfunction will take care of setting the css class and remove it from other days.Of course you can extend this to work with multiple selected dates, this is just to show where you can start.