其实我就一个地方一直没想不通
图片一(正常效果)
图片二
$(function () { var date = new Date(); var firstDate = new Date(date.getFullYear(), date.getMonth(), 1); var lastDate = new Date(date.getFullYear(), date.getMonth() + 1, 0); $("#result").append("firstDate getDay= " + firstDate.getDay() +" <br/>"); $("#result").append("lastDate getDate= " + lastDate.getDate() +" <br/>"); $("#result").append("Date getMonth= " + (date.getMonth()+1) +" <br/>"); // 设置年月 $('h2').text(date.getFullYear() + '/' + (date.getMonth() + 1)); // 设置星期 var week = ['日', '一', '二', '三', '四', '五', '六']; $.each(week, function(index, value) { if (index == 0) { $('<li/>').text(value).css('backgroundColor', '#f00').appendTo('ul'); } else { $('<li/>').text(value).appendTo('ul'); } }); // 设置日期 var calendarNum = (firstDate.getDay() + lastDate.getDate()) <= 35 ? 7 * 5 : 7 * 6; var day = 0; $.each((new Array(calendarNum)), function(index, value) { var dayValue = ''; if (index >= firstDate.getDay() && day < lastDate.getDate()) { day++; dayValue = (date.getMonth() + 1) + '/' + day; } var myday = new Date(date.getFullYear(), date.getMonth(), day); $("#result").append(myday.toString()+" getDay= " + myday.getDay() + "<br/>"); if ((new Date(date.getFullYear(), date.getMonth(), day).getDay()) == 0 && dayValue != '') { $('<li/>').text(dayValue).css('backgroundColor', '#f00').appendTo('ul'); } else { $('<li/>').text(dayValue).appendTo('ul'); } }); // 指定多个选择设置 $('ul').selectable({ filter: 'li:contains(' + (date.getMonth() + 1) + '/)', stop: function() { var result = $('#result').empty(); $('.ui-selected', this).each(function(){ result.append('<' + $(this).text() + '>'); }); } });});
<body><div id="header"><h1>元素选择</h1><!-- #header --></div><div class="container"><div id="container"><h2></h2><ul></ul><div id="result"></div><!-- #container --></div><!-- .container --></div><div id="footer"><!-- #footer --></div></body>
如需要阅读该回复,请登录或注册CSDN!
如需要阅读该回复,请登录或注册CSDN!