【发布时间】:2023-03-15 17:50:02
【问题描述】:
我几乎是 jquery 的新手。我有一个用于日历的 PHP 类,其中一个函数返回 jquery 代码的一部分。事实上,我想禁用日历中的特定日期,这些日期对于各种数据库查询是不同的。我可以传递变量,在 IE 的源代码中,我看到的变量是这样的:$(#datepicker1).datepicker,但是当它是静态的时,它看起来像 $("#datepicker1").datepicker。尽管在第一种样式中,变量类型是字符串,但它不理解它是一个html标签ID,并且它不会对那个标签应用方法。 这是 PHP 类中的主要函数:
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 传递数据
标签: php jquery class variables