jQuery Date Input 功能单一的日历插件,小而精。
属于jquery插件
点此下载:jonleighton-date_input-332e62f
在应用过程中配合jquery1.7.1时报错,需要修改两行数据
104行修改为
$('td[date= "'+ this.dateToString(new Date()) +'"]', this.tbody).addClass("today");
111行修改为
$('td[date="' + this.selectedDateString + '"]', this.tbody).addClass("selected");
附件中未包含,需自行修改。
1,Include jQuery
2,Include jquery.date_input.js
3,Include date_input.css
4,如果默认样式为.date_input 可以直接
$($.date_input.initialize);
5,通用加载
$(function() { $("#my_specific_input").date_input(); });
6,覆盖语言包的例子
jQuery.extend(DateInput.DEFAULT_OPTS, { month_names: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"], short_month_names: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"], short_day_names: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sab"] });
7,日期样式更新
$.extend(DateInput.DEFAULT_OPTS, { stringToDate: function(string) { var matches; if (matches = string.match(/^(d{4,4})-(d{2,2})-(d{2,2})$/)) { return new Date(matches[1], matches[2] - 1, matches[3]); } else { return null; } }, dateToString: function(date) { var month = (date.getMonth() + 1).toString(); var dom = date.getDate().toString(); if (month.length == 1) month = "0" + month; if (dom.length == 1) dom = "0" + dom; return date.getFullYear() + "-" + month + "-" + dom; } });
《“jQuery Date Input 功能单一的日历插件,小而精”》 有 1 条评论
真的不错,谢谢