收藏的乙個js日曆控制項

2021-04-21 15:04:34 字數 1975 閱讀 3033

收藏的乙個js日曆控制項

setday.js

function cnverycalendar()

if (y % 100 == 0)

return 29;}}

//generate codes

this.generatecalendartable = function()

//loop each days in current month

for (i=1; i<=k; i++)

//cells day by day

body += "" + i + "";

//row end

if ((i+j) % 7 == 0)

}");

}if (j == 0 && k == 28)

//end calendar table

body += "";

//end frame table

body += "

";//return

return body;

}//load previous year

this.loadpreviousyear = function()

this.loadnextyear = function()

this.loadpreviousmonth = function()

__cnverycalendarcontainer.innerhtml = this.generatecalendartable();

}this.loadnextmonth = function()

__cnverycalendarcontainer.innerhtml = this.generatecalendartable();

}//get position

this.getabsoluteposition = function(element)

;//recursion

if (element.offsetparent)

return point;

};//pop layer

this.sethook = function(datefield)

reciever = datefield;

//-- 如果不想在第二次開啟日歷時回歸為當前月,則把下面兩行注釋掉或刪掉 --

y = today.getfullyear();

m = today.getmonth() + 1;

//----------------------------

var point = this.getabsoluteposition(datefield);

// __cnverycalendarcontainer.style.left = (point.x + datefield.offsetwidth + 5) + 'px';

// __cnverycalendarcontainer.style.top = point.y + 'px';

__cnverycalendarcontainer.style.left = (point.x ) + 'px';

__cnverycalendarcontainer.style.top =  (point.y + 20) + 'px';

__cnverycalendarcontainer.innerhtml = this.generatecalendartable();

__cnverycalendarcontainer.style.display = '';

}//hide layer

this.fadeout = function()

//click a day cell to add the value

this.setvalue = function(date)

}//render instance

document.write("

");var calendar = new cnverycalendar();

呼叫:

乙個簡單的日曆控制項

效果圖 var defaultdate new date var startyear,startmonth,startday 變數定義需要改一下,用default來定義當天的所有資訊 不能改變 var defaultmonth defaultdate.getmonth var defaultyear...

乙個css jq的日曆控制項

剛畢業,閒著的時候做了乙個日曆控制項,用css和jquery實現基本的日曆功能,包括年份和月份的翻頁,日期的選擇,根據輸入框的初始內容來初始化控制項,日期改變之後,也會更新該輸入框的內容。首先是css charset utf 8 css document x date date body date ...

js寫乙個定製日曆

老早之前寫過乙個js日曆的方法,但是和dom耦合太強,並且邏輯複雜化,在原來的基礎上進行了優化,重寫了日曆方法。效果圖如下,dom結構為乙個div,裡面包含了 7 6 42 個元素,左浮動排列 原始碼如下 日曆控制項 var dw new dateweek dt new date dw.setdat...