我目前正在制作日历。我在制作日历容器滚动时遇到了困难。javascript 在包含所有日期的计划日期容器中生成日期。它还将生成一个全尺寸的日历,在其中可以显示内部的各种对象。我遇到的问题是我试图让滚动工作。当我单击计划日期容器中的数字时,它会将全尺寸日历滚动到该特定日期,但我很难对滚动部分进行编码。我在这里先向您的帮助表示感谢。
<p>
<div id='schedule-date-background'>
<div id='schedule-date-container'>
</div>
</div>
<div id="schedule-overall-frame">
<div id='schedule-overall-container'>
</div>
</div>
</p>
// JavaScript 文档$(document).ready(function () {
//Global Variables
var week = [14,15,16,17,18,19,20,21,22,23,24,25,26,27];
var today = new Date();
var day = today.getDate();
//End of Global Variable
//Dates loaders
function LoadDates()
{
for (var i = 0; i < week.length; i++)
{
//add <div id="today"> to the schedule
if (day==week[i]){
var ObjDiv = $('<div></div>');
ObjDiv.addClass(i);
ObjDiv.addClass("schedule-date-minicontainer");
ObjDiv.addClass("today");
ObjDiv.append(week[i]);
$('#schedule-date-container').append(ObjDiv);
}
//generate dates
else{
var ObjDiv = $('<div></div>');
ObjDiv.addClass(i);
ObjDiv.addClass("schedule-date-minicontainer");
ObjDiv.append(week[i]);
$('#schedule-date-container').append(ObjDiv);
}
}
var container = 0;
for (var i=0; i<week.length; i++)
{
var ObjDiv = $('<div></div>');
ObjDiv.addClass("schedule-stripcontainer");
ObjDiv.append(week[i]);
$('#schedule-overall-container').append(ObjDiv);
if (day==week[i]){
container = "230" * (i-1);
}
}
/*document.getElementById("schedule-overall-container").style.marginLeft = -container + "px" ;*/
$('div#schedule-overall-container').animate({'left': -container}, 'slow')
}
//End of Dates Loader
$(document).ready(function () {
document.getElementsByClassName('0').click(function () {
document.getElementsByClassName('0').animate({'left': '+=230px'}, 'slow');
$('div#schedule-overall-container').animate({'left': '+=230px'}, 'slow');
});
$('.1').click(function () {
document.getElementsByClassName.animate({'left': '+=230px'}, 'slow');
$('div#schedule-overall-container').animate({'left': '+=230px'}, 'slow');
});