0

Basically what I would like to accomplish is having a variable value inside the onSelect function. This value will be set in the Dom ready function. I need this variable to execute a function called checkDates everytime there is a change in the date picker.

jQuery(function(){  
  var myVar = 'xzy';
}); 

$("#PeriodStartDate").datepicker({            
  onSelect: function(dateText) {          
    console.log(myVar);
    checkDates(this.value, $('#EffectiveStartDate').val(), myVar);        
  }
});
4

1 回答 1

1
var myVar;
jQuery(function(){  
         myVar = 'xzy';
    }); 

$("#PeriodStartDate").datepicker({            
        onSelect: function(dateText) {          
            console.log(myVar);
            checkDates(this.value,$('#EffectiveStartDate').val(),myVar);        
        }
    });
于 2017-09-12T08:18:43.350 回答