爱易网
IT新闻
IT新闻
爱易资讯
网站搭建
云虚拟主机教程
云服务器教程
Apache教程
IIS教程
Nginx教程
网站策划
站长文章
推广教程
淘宝客教程
网页设计
HTML教程
XHTML教程
CSS教程
HTML5教程
CSS3教程
JavaSript基础
JQuery教程
Node.js教程
前端技术
Ajax教程
Js特效
Xml教程
平面设计
页面UI设计
photoshop教程
程序开发
AI人工智能
Asp教程
Php教程
Asp.Net教程
Net Core教程
C#教程
Java教程
Jsp教程
开发技术
微信小程序教程
Uniapp开发教程
微信公众号开发
Andriod教程
IOS教程
DOS教程
Python教程
Docker教程
Windows Container教程
数据库
MSSQL教程
MySQL教程
Redis教程
Access教程
Oracle教程
数据库教程
操作系统
Linux教程
Windows教程
MAC教程
Cisco教程
交换机教程
防火墙教程
搜索
爱易网页
JS特效
一款简单的日历选择器特效
一款简单的日历选择器特效
日期:2014-05-18 浏览次数:20274 次
以下是程序代码
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>DatePicker</title> <meta name="author" content="hongru.chen" /> <style> .date-picker-wp { display: none; position: absolute; background: #f1f1f1; left: 40px; top: 40px; border-top: 4px solid #3879d9; } .date-picker-wp table { border: 1px solid #ddd; } .date-picker-wp td { background: #fafafa; width: 22px; height: 18px; border: 1px solid #ccc; font-size: 12px; text-align: center; } .date-picker-wp td.noborder { border: none; background: none; } .date-picker-wp td a { color: #1c93c4; text-decoration: none; } .strong {font-weight: bold} .hand {cursor: pointer; color: #3879d9} </style> <script type="text/javascript"> var DatePicker = function () { var $ = function (i) {return document.getElementById(i)}, addEvent = function (o, e, f) {o.addEventListener ? o.addEventListener(e, f, false) : o.attachEvent('on'+e, function(){f.call(o)})}, getPos = function (el) { for (var pos = {x:0, y:0}; el; el = el.offsetParent) { pos.x += el.offsetLeft; pos.y += el.offsetTop; } return pos; } var init = function (n, config) { window[n] = this; Date.prototype._fd = function () {var d = new Date(this); d.setDate(1); return d.getDay()}; Date.prototype._fc = function () {var d1 = new Date(this), d2 = new Date(this); d1.setDate(1); d2.setDate(1); d2.setMonth(d2.getMonth()+1); return (d2-d1)/86400000;}; this.n = n; this.config = config; this.D = new Date; this.el = $(config.inputId); this.el.title = this.n+'DatePicker'; this.update(); this.bind(); } init.prototype = { update : function (y, m) { var con = [], week = ['Su','Mo','Tu','We','Th','Fr','Sa'], D = this.D, _this = this; fn = function (a, b) {return '<td title="'+_this.n+'DatePicker" class="noborder hand" onclick="'+_this.n+'.update('+a+')">'+b+'</td>'}, _html = '<table cellpadding=0 cellspacing=2>'; y && D.setYear(D.getFullYear() + y); m && D.setMonth(D.getMonth() + m); var year = D.getFullYear(), month = D.getMonth() + 1, date = D.getDate(); for (var i=0; i<week.length; i++) con.push('<td title="'+this.n+'DatePicker" class="noborder">'+week[i]+'</td>'); for (var i=0; i<D._fd(); i++ ) con.push('<td title="'+this.n+'DatePicker" class="noborder"> </td>'); for (var i=0; i<D._fc(); i++ ) con.push('<td class="hand" onclick="'+this.n+'.fillInput('+year+', '+month+', '+(i+1)+')">'+(i+1)+'</td>'); var toend = con.length%7; if (toend != 0) for (var i=0; i<7-toend; i++) con.push('<td class="noborder"> </td>'); _html += '<tr>'+fn("-1, null", "<<")+fn("null, -1", "<")+'<td title="'+this.n+'DatePicker" colspan=3 class="strong">'+year+'/'+month+'/'+date+'</td>'+fn("null, 1", ">")+fn("1, null", ">>")+'</tr>'; for (var i=0; i<con.length; i++) _html += (i==0 ? '<tr>' : i%7==0 ? '</tr><tr>' : '') + con[i] + (i == con.length-1 ? '</tr>' : ''); !!this.box ? this.box.innerHTML = _html : this.createBox(_html); }, fillInput : function (y, m, d) { var s = this.config.seprator || '/'; this.el.value = y + s
上一篇:狡猾的按钮特效
下一篇:以4位数字格式,显示时间的毫秒数值
免责声明:
本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
相关资料
更多>
Twitter收购印度手机营销公司ZipDial
史玉柱谈创业:5大建议 失败的教训最真实
墨迹也要做硬件,工具类应用如何“变异”的
途牛开盘价9美元 与发行价持平
赴美开店,阿里11Main准备好了吗?
继续涨:微博IPO第二交易日 收盘大涨11.71%
FDD牌照短期不会发放 联通电信暗自提速建网
虚拟运营商温度有多高?降温OR升温内外有别
传360周鸿祎曾试图阻止百度收购91无线
推荐阅读
更多>
永不磨灭的九大尖端编程语言
阿里巴巴450亿勾画“现代服务业”藏宝图
曹国伟:微博将关注Facebook和Twitter
微软最后的救命稻草Win 8份额继续上升
戴尔新CEO名单曝光:惠普甲骨文高管在列
《中国三网融合业务运营管理》研讨报告征订函
微软与摩托罗拉授权协议涵盖Android和Chrome设备
中移动财报外的"五座大山":运营商沦为走秀陪衬
微软张亚勤趋势判断:未来三十年属于物理化互联网
国内云服务商存在尴尬:“远程机房+移动大硬盘”模式
阿里巴巴IPO难掩的四个现实问题:天猫销售额成谜、淘宝拖后腿、营收迅猛其他不行和投资者未必买账
中电信率先推移动转售业务 中下旬批量上市
中国大陆人口13.7亿 光棍越来越多
宽带中国战略明确 运营商建设成本超6000亿
Kindle入华遭遇国内厂商“围剿 ” 电信也参战
虚拟运营商前路迷茫 业界建议发力车联网
都是300元内 乐视盒子与小米盒子对比体验
英特尔VS苹果:移动芯片大战
淘宝公布新规:升级售假卖家惩罚力度
盘点改变社会的15种科技:谷歌眼镜将使我们成为半机械人