我寫一個自定義日曆,是由兩個部分組成,一個DIV顯示當月網格,第二格顯示爲事件所選日期。當前月份的日曆網格會自動加載,並且日常事件的顯示可以正常顯示。但是,當用戶單擊按鈕查看下一個或上個月時,單擊日期不再有效。另外,更改月份不再適用於動態加載的日曆。我的腳本適用於靜態內容很好,但是當內容是通過AJAX改變遊 - jQuery的
這是我使用jQuery代碼:直接使用click
<script type="text/javascript">
$(document).ready(
function() {
$('div.calendar_events').text('To view the events on any of the highlighted dates, simply click the date.');
$('div.number').click(
function(e) {
e.preventDefault();
var theDate = $(this).attr('id').split('-');
$('div.calendar_events').load('ajax/calendar_events.php?month=' + theDate[1] + '&day=' + theDate[2] + '&year=' + theDate[3]);
});
$('a.changemonth').click(
function(e) {
e.preventDefault();
var theDate = $(this).attr('id').split('-');
$('div.calendar').load('ajax/calendar_view.php?month=' + theDate[1] + '&year=' + theDate[2]);
});
});
</script>