Я хотел спросить.Почему .attr("title")
не работает?В заголовке указывается дата календаря, например: «2011712», и мне нужно вставить ее в подстроку .. Но когда я делаю это, ничего не происходит?
РЕДАКТИРОВАТЬ: событие tap работает нормально ... но я не получаю "Заголовок"в тексте заголовка ..
Нажмите событие->
$('.div-cell').tap(function() {
var i;
for (i = 0; i < 42; i++) {
$('#' + i + 'dayCell').removeClass('tapped');
}
$(this).toggleClass(
'tapped');
var myDate2 = $(this).attr("title").substring(5,7) +" "+ months[$(this).attr("title").substring(4,5)];
$('#MSchedule header h4').text("Schedule - " + myDate2);
});
Создание календаря ->
function setCalendar() {
var cTime = new Date();
var myDate = months[cTime.getMonth()] + " " + cTime.getFullYear();
var myDate2 = cTime.getDate() + " " + months[cTime.getMonth()];
$('#MCalendar header h4').text(myDate);
$('#MSchedule header h4').text("Schedule - " + myDate2)
var monthView = new Array(42);
var firstDayOfMonth = new Date(cTime.getFullYear(), cTime.getMonth(), 1);
while (firstDayOfMonth.getDay() != 1) {
firstDayOfMonth.addDays(-1);
}
var i;
for (i = 0; i < monthView.length; i++) {
startDate = new Date(firstDayOfMonth);
monthView[i] = startDate.addDays(i);
}
var day = 0;
$("#calendar")
.children()
.each(
function() {
var row = $(this);
if ($(this).hasClass('weekdays')) {
} else {
row
.children()
.each(
function() {
var cell = $(this);
var content = '<div class="dayNumberCellValue" title="' + monthView[day].getYear()+
monthView[day].getMonth()+monthView[day].getDate()+ '">'
+ monthView[day]
.getDate()
+ '</div>';
cell.append(content);
if (monthView[day]
.getMonth() != Date
.today().getMonth()) {
$(this).addClass(
'otherMonth');
} else {
if (Date
.today()
.equals(
monthView[day])) {
$(this).addClass(
'today');
}
$(this).addClass(
'noRecords');
}
day++;
});
}
});
$(".div-cell:contains('16')").removeClass('noRecords').addClass(
'hasRecords');
$(".div-cell:contains('17')").removeClass('noRecords').addClass(
'hasRecords');
$(".div-cell:contains('18')").removeClass('noRecords').addClass(
'hasRecords');
$(".div-cell:contains('20')").removeClass('noRecords').addClass(
'onVacation');
$(".div-cell:contains('21')").removeClass('noRecords').addClass(
'onVacation');
$(".div-cell:contains('22')").removeClass('noRecords').addClass(
'onVacation');
}
РЕДАКТИРОВАТЬ: HTML ->
<div id="calendar">
<div class="div-row weekdays">
<div class="div-cell-weekdays"></div>
<div class="div-cell-weekdays"></div>
<div class="div-cell-weekdays"></div>
<div class="div-cell-weekdays"></div>
<div class="div-cell-weekdays"></div>
<div class="div-cell-weekdays"></div>
<div class="div-cell-weekdays"></div>
</div>
<div class="div-row">
<div id="0dayCell" class="div-cell"></div>
<div id="1dayCell" class="div-cell"></div>
<div id="2dayCell" class="div-cell"></div>
<div id="3dayCell" class="div-cell"></div>
<div id="4dayCell" class="div-cell"></div>
<div id="5dayCell" class="div-cell"></div>
<div id="6dayCell" class="div-cell"></div>
</div>
<div class="div-row">
<div id="7dayCell" class="div-cell"></div>
<div id="8dayCell" class="div-cell"></div>
<div id="9dayCell" class="div-cell"></div>
<div id="10dayCell" class="div-cell"></div>
<div id="11dayCell" class="div-cell"></div>
<div id="12dayCell" class="div-cell"></div>
<div id="13dayCell" class="div-cell"></div>
</div>
<div class="div-row">
<div id="14dayCell" class="div-cell"></div>
<div id="15dayCell" class="div-cell"></div>
<div id="16dayCell" class="div-cell"></div>
<div id="17dayCell" class="div-cell"></div>
<div id="18dayCell" class="div-cell"></div>
<div id="19dayCell" class="div-cell"></div>
<div id="20dayCell" class="div-cell"></div>
</div>
<div class="div-row">
<div id="21dayCell" class="div-cell"></div>
<div id="22dayCell" class="div-cell"></div>
<div id="23dayCell" class="div-cell"></div>
<div id="24dayCell" class="div-cell"></div>
<div id="25dayCell" class="div-cell"></div>
<div id="26dayCell" class="div-cell"></div>
<div id="27dayCell" class="div-cell"></div>
</div>
<div class="div-row">
<div id="28dayCell" class="div-cell"></div>
<div id="29dayCell" class="div-cell"></div>
<div id="30dayCell" class="div-cell"></div>
<div id="31dayCell" class="div-cell"></div>
<div id="32dayCell" class="div-cell"></div>
<div id="33dayCell" class="div-cell"></div>
<div id="34dayCell" class="div-cell"></div>
</div>
<div class="div-row">
<div id="35dayCell" class="div-cell"></div>
<div id="36dayCell" class="div-cell"></div>
<div id="37dayCell" class="div-cell"></div>
<div id="38dayCell" class="div-cell"></div>
<div id="39dayCell" class="div-cell"></div>
<div id="40dayCell" class="div-cell"></div>
<div id="41dayCell" class="div-cell"></div>
</div>
</div>