(function($);
var opts = $.extend({}, defaults, options);
var $yearselector = $(opts.yearselector);
var $monthselector = $(opts.monthselector);
var $dayselector = $(opts.dayselector);
var firsttext = opts.firsttext;
var firstvalue = opts.firstvalue;
// 初始化
var str = "" + firsttext + "";
$yearselector.html(str);
$monthselector.html(str);
$dayselector.html(str);
// 年份列表
var nowdate=new date(),
yearnow = nowdate.getfullyear(),
monthnow=nowdate.getmonth()+1,
daynow=nowdate.getdate(),
yearsel = $yearselector.attr("rel"),
yearstr="";
for (var i = yearnow; i >= 1900; i--)
// 月份列表
var monthsel = $monthselector.attr("rel");
buildmonth();
function buildmonth()
var currentmonth=opts.currentyear==$yearselector.val()?monthnow:12;
var monthstr="";
for (var i = 1; i <=currentmonth; i++)
$monthselector.html(monthstr);
}// 日列表(僅當選擇了年月)
function buildday() else
break;
default:
break;
}var daysel="";
if($dayselector.val()!=0)else
$dayselector.html(str);
var currentmonth=0;
if(opts.currentmonth==0)
if(opts.currentday==0)
//當前選擇的年份是今年,同時月份也是當前月,設定日不能超過初始化的日
if(opts.currentyear==$yearselector.val())
var daystr="";
for (var i = 1; i <= daycount; i++)
$dayselector.html(daystr);}}
$monthselector.change(function () );
$yearselector.change(function () );
if($dayselector.attr("rel")!="")
} // end ms_datepicker
});})(jquery);
呼叫示例:
$.ms_datepicker();
jQuery年月日(生日)選擇器
我們在編輯使用者資料時經常會遇到選擇生日選項的問題,今天我給大家介紹如何使用js來實現年月日 生日 選擇器,能夠準確計算閏年的年月日,方便表單處理。html 生日中的年月日以下拉方式,我們給每個select加個rel屬性,當已知使用者生日日期的,直接通過rel屬性標註,外掛程式會將rel屬性值轉換成...
jquery下拉列表
由於需要 用以前發過的摺疊選單原始碼改了一下 做成了下拉列表 感覺還不錯 留著以後使用 首頁主選單.子選單.子選單.子選單.子選單.子選單.子選單.主選單.子選單.子選單.子選單.子選單.子選單.子選單.主選單.子選單.子選單.子選單.子選單.子選單.子選單.主選單.子選單.子選單.子選單.子選單....
jquery選擇下拉框觸發事件的實現
因為jquery選擇下拉框觸發事件的實現而焦頭爛額,先前我用了對下拉框option中的id用了click事件,在火狐中竟然能執行而在其他瀏覽器卻不行,這讓我一度以為是瀏覽器相容問題。錯錯錯,option中沒有id也沒有click事件。我的天,超級發現問題超級開心。下面是我的實現。bind 方法為被選...