//計算年齡 calcAge : function(birthday, calcDate){ var num = (calcDate.getMonth()<birthday.getMonth() || calcDate.getMonth()==birthday.getMonth() && calcD ...
//計算年齡
calcAge : function(birthday, calcDate){
var num = (calcDate.getMonth()<birthday.getMonth() || calcDate.getMonth()==birthday.getMonth() && calcDate.getDate()<birthday.getDate())?1:0;
return calcDate.getFullYear()-birthday.getFullYear() - num;
},
//字元串轉日期
string2Date : function(date){
var sd = date.split('-');
return new Date(sd[0],sd[1] - 1,sd[2]);
},
//日期轉字元串
date2String : function(data) {
if (!data) {
return "";
}
var date = new Date(data);
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
month = month >= 10 ? month : "0" + month;
day = day >= 10 ? day : "0" + day;
return year + "-" + month + "-" + day;
},
//點全選checkbox
checkAll : function (){
var checked = $("#checkAllBox").prop("checked");
$('input[name="subCheckbox"]').prop('checked',checked);
},
//若有項目取消勾選,全選取消,否則全選勾選
ifCheckAll : function (){
var roles = $('input[name="subCheckbox"]');
for(var i = 0 ; i < roles.length ; i++){
if(!roles[i].checked){
$("#checkAllBox").prop("checked",false);
return;
}
}
$("#checkAllBox").prop("checked",true);
},