我嘗試操作jQuery的日期選擇器,因爲我想要一個多選。 現在我想更改所選日期的樣式,例如將文本設爲綠色。 我不知道,我可以如何改變風格。有什麼可能嗎?jQuery:添加樣式到日期選擇器中的選定日期
感謝您的幫助!
這裏是我的代碼:
$(".testpicker").datepicker({
numberOfMonths: 2,
showButtonPanel: false,
onSelect: function(test,object){
console.log(object.id);
//#####My first tries######//:
$("#"+object.id).css('color','green');
$(this).css('background-color','white');
//###########//
if(~$.inArray(test,dates))
{
console.log(test)
}
else
{
dates.push(test);
}
console.log(dates);
console.log(object);
//prevents closing
$(this).data('datepicker').inline = true;
},
onClose: function() {
$(this).data('datepicker').inline = false;
}
});
那是對的,但是我如何才能在選定的日期訪問?如果它是這樣的元素「$(」#「+ object.id).css('color','green');」這將是沒有問題,但一天在一個表中,它看起來像這樣:
再次如果你檢查datepicker html,你會發現每個單元格只是其中裏面。嘗試把你的點擊事件放在那個上 – 2013-05-13 10:53:02