嗨,我是 jquery 和 jquery mobile 的新手,我正在参加使用以下JQM-Calendar创建活动日历。现在我想检查这个日期是否有活动我显示消息
日期有一个事件
或日期没有事件我将消息显示为
该日期没有活动
. 如何在我的代码中检查这个
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<link rel="stylesheet" href="jw-jqm-cal.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript" src="jw-jqm-cal.js"></script>
<script type="text/javascript">
$(document).on('pageshow', "#view-calendar", function(event, ui) {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$("#calendar").jqmCalendar({
events: [{
"summary": "Meet PM",
"begin": new Date(y,m, 27 ),
"end": new Date(y, m, 28)
}, {
"summary": "Dinner",
"begin": new Date(y, m, d + 3),
"end": new Date(y, m, d + 4)
}, {
"summary": "Lunch with Friends",
"begin": new Date(y, m, d + 6),
"end": new Date(y, m, d + 7)
},
],
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
days: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
startOfWeek: 0
});
$("#calendar").bind('change', function(event, date) {
$("#message").html('<p><strong>There is No event at '+date+' </strong></p>');
});
});
</script>
</head>
<body>
<div data-role="page" id="view-calendar">
<div data-role="header">
<h1>Tradition Calendar</h1>
</div>
<div data-role="content">
<div id="calendar"></div>
<div id="message"></div>
</div>
</div>
</body>
通过这种方式,我找到了哪个日期有事件并显示消息。这样如何检查另一个日期没有事件