jquery的日期外掛程式有好幾款,h5中的input也可以自帶日期選擇。但為什麼要再寫乙個,有兩個理由,乙個是引用的檔案太大,而有時候只需要很簡單的功能,二個是想加一些自定義的效果不好改。
我寫的這個功能比較簡單,可以換月,有預約效果,可以設定預約日期範圍,壓縮後1.4kb,先上個圖,再慢慢解釋:
console.log("最小日期是:",mindate.format("yyyy-mm-dd"))
console.log("最大日期是:",maxdate.format("yyyy-mm-dd"))
console.log("當前日期:",currentdate())
pain();
function pain()
str += ""; //**的行結束
}str += "" + ynow + "年" + (mnow + 1) + "月
"; str += ""; //**結束
$ele.html(str);
setdate(ynow, mnow, dnow);
}function setdate(y, m, d)
function currentdate()
self.prev=function() else
var temp = mnow + 1;
if (temp > 11) else
if(ynow==maxdate.getfullyear()&&mnow==maxdate.getmonth())
pain();
}self.seleted=function($td)
$(".datebox table td").removeclass('selected').children('.subscribe').remove();
$td.addclass('selected');
$td.html('' + $td.html() + '
預約');
dnow=day;
setdate(ynow, mnow, day);}}
self.getdate=function()
$ele.on("click", "table td", function () );
config.$prev.click(function () );
config.$next.click(function () );
return self;
}css:隨便玩了。
body
*.content
.datetitle
.datetitle:before
.datebox
.datebox table
.datebox table td
.datebox table td div
.datebox table td.selected
.datebox table td.selected .subscribe
.datebox table td .subscribe
.datebox table tfoot td
.databox #up ,.databox #down
.datetitle #down
.datetitle #up
.datetitle #up:hover ,.datetitle #down:hover
body公布了isleap,next,prev,getdate,seleted 五個方法(看名字就不需要解釋了吧)。預設今天是最小的預約時間。*.content
.datetitle
.datetitle:before
.datebox
.datebox table
.datebox table td
.datebox table td div
.datebox table td.selected
.datebox table td.selected .subscribe
.datebox table td .subscribe
.datebox table tfoot td
.databox #up ,.databox #down
.datetitle #down
.datetitle #up
.datetitle #up:hover ,.datetitle #down:hover
換月的時候日期會自動切換到可預約的日期。
輕量級的cookie 外掛程式
乙個輕量級的cookie 外掛程式,可以讀取 寫入 刪除 cookie。jquery.cookie.js 的配置 首先包含jquery的庫檔案,在後面包含 jquery.cookie.js 的庫檔案。使用方法 1.新新增乙個會話 cookie cookie the cookie the value ...
Jqprint 輕量級頁面列印外掛程式
最近專案中需要在頁面上新增乙個列印的按鈕,上網搜尋了一下就發現了這個好用的超輕量外掛程式,使用起來很方便 1.首先需要引入必須的js檔案 2.之後只要找到需要列印的頁面區域 jqprint 即可 比如 列印 這裡是要列印的內容 就會呼叫瀏覽器的列印功能來列印id為print中的內容 3.jqprin...
輕量級jQuery網格外掛程式 ParamQuery
paramquery是一種輕量級的jquery網格外掛程式,基於用於使用者介面控制 具有一致api的優秀設計模式jqueryui widget factory建立,能夠在網頁上展示各種類似於excel和google spreadsheet效果的網格。使用paramquery,開發者可以輕鬆地實現以下...