jQuery Datepicker BeforeShowDay Second Parameter

jQuery’s datepicker allows you to highlight dates using the BeforeShowDay callback.

Is it possible to pass a second parameter to the method?

  • jQuery datepicker minDate variable
  • jQuery datepicker without input
  • datepicker parsing date issue
  • jQuery ui datepicker not working in Firefox
  • Angular UI Datepicker Isn't Receiving Updated Scope Variable In Dates-Disabled Function
  • Jquery .live works but not with .datepicker
  • $(selector).datepicker({beforeShowDay: selectedDay});   
    function selectedDay(date) {
        // Do stuff
        return [true, 'class_name'];

    As you can see, the parameter date is automatically passed to the selectedDay method, thus making me unsure as to how to pass a second parameter.


  • Display date picker below input field
  • AngularStrap datepicker shows wrong date
  • Bootstrap Datepicker (avoid text input or restrict manual input)
  • Bootstrap datepicker format date differently on display than on value
  • how to disable dates before today in jQuery datepicker
  • jquery UI datepicker transparent background
  • 4 Solutions collect form web for “jQuery Datepicker BeforeShowDay Second Parameter”

    I was wondering about the same question and I think I found the answer:

    function selectedDay(date, param ) {
         // Do stuff with param
         return [true, ''];
    function doStuff(){
        var param = "param_to_pass";
            beforeShowDay: function (date){
                return selectedDay(date, param );

    If I understand correctly, you can just create another function and pass any params you want:

    function foo (param) { ... }
    function selectedDay (date) {
      return [true, 'class_name'];
    $(selector).datepicker({beforeShowDay: selectedDay});   

    You can write a function which returns an array of dates

    function selectedDay(date1,date2) {
    // your code
    return dates[];

    and then

    $(selector).datepicker({beforeShowDay: selectedDay});  

    just an idea, absolutely not sure if it works

    I resorted to not-the-best-practice to solve my issue. I simply made the second parameter to pass a global. It’ll do the job for the time being.

    $(selector).datepicker({beforeShowDay: selectedDay});   
    var my_param = x;
    function selectedDay(date) {
        // Do stuff, use my_param
        return [true, 'class_name'];