我幾乎是新的jquery。我有一個日曆的PHP類,其中一個函數返回一部分jQuery代碼。事實上,我想禁用一個calnder中的特定日期,這些日期對於各種數據庫查詢是不同的。我可以傳遞變量,並在IE中的源代碼中,我看到這樣的變量:$(#datepicker1).datepicker,但是當它是靜態的,它看起來像$(「#datepicker1」)。datepicker。雖然在第一種風格中,變量類型是字符串,但它不明白它是一個html標籤ID,並且它不適用該Tag上的方法。 這是PHP類中的主要功能:將字符串變量傳遞給php類中的jQuery代碼
function createCal($month, $day, $id)
{
//echo('#'.($this->datePickerID));
$ids=("#datepicker".$id);
echo($ids);
return<<<html
<script>
$(function() {
//-----------------------------------
$($ids).datepicker({
beforeShowDay: function(date) {
//alert(date.getDate());
if (date.getDay()==5 ||(date.getMonth()==$month && date.getDate() == $day))
return [false, '', 'weekends'];
return [true];
}
});
});
,這是從IE
源代碼<script>
$(function() {
//-----------------------------------
$(#datepicker1).datepicker({
beforeShowDay: function(date) {
//alert(date.getDate());
if (date.getDay()==5 ||(date.getMonth()==0 && date.getDate() == 26))
return [false, '', 'weekends'];
return [true];
}
});
});
</script>
<p class='ui-widget-content'>
date:
<input type="text" id="datepicker1" />
</p>
使用JSON來傳遞你的數據 –