有人可以从datepicker解释这行代码

时间:2014-05-16 14:54:58

标签: jquery

我正在使用以下Jquery脚本http://www.eyecon.ro/datepicker

现在我正在进行一些调整并遇到以下代码行,我不完全理解它,所以你能告诉我发生了什么吗?

var fromUser = options.onRender(date);
var val = date.valueOf();
if (fromUser.selected || options.date == val || $.inArray(val, options.date) > -1 || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) {
data.weeks[indic].days[indic2].classname.push('datepickerSelected');
}

1 个答案:

答案 0 :(得分:1)

//date picked by user
var fromUser = options.onRender(date); 
var val = date.valueOf();


if (fromUser.selected //if date is selected
    || options.date == val //date is set in options
    || $.inArray(val, options.date) > -1 //date exists in options
    || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) //if date is in between the selected range of two pickers
{
    //mark the selected date by adding the class name of 'datepickerSelected' to the date-container in the picker
    data.weeks[indic].days[indic2].classname.push('datepickerSelected'); 
}