自己编写的手机端周历插件

    一直想找一个手机端的关于行事历的周历插件,在手机日历上这种效果很常见,但是基于js开发的却很少见,我所知道的就只有fullcalendar,但是这种并不是我想要的效果,在网上搜索了很久也找不到合适的,最后无奈只好自己编写。

    该周历插件是基于jQuery编写的,可以左右点击切换上下周,也可以左右滑动切换上下周,点击日期可以返回对应的日程记录,是很简单的一款行事历插件。截图如下:


css代码如下:


*{
	margin: 0;
	padding: 0;
}
.week-container{
	width: 100%;
	overflow: hidden;
	margin:0 auto;
	font-family: 'Microsoft YaHei';
	font-size: 16px;
}
.week-container .week_head{
	margin:5px 0;
}
.week-container .week_head span{
	display: inline-block;
	height: 36px;
	padding:0 20px;
	background: #f00;
	border-top-right-radius: 40px;
	border-bottom-right-radius: 40px;
	color: #fff;
	line-height: 36px;
	font-size: 16px;
}
.time{
	position: relative;
}
.week-container .button_prev,.week-container .button_next{
	width:30px;
	height: 30px;
	display: block;
	border: 1px solid #f00;
	color: #f00;
	text-align: center;
	line-height: 30px;
	position: absolute;
	top:50%;
	margin-top:-15px;
	border-radius: 50%;
	text-decoration: none;
	font-size: 26px;
	z-index: 9;
}
.week-container .button_prev{
	left:0;
}
.week-container .button_next{
	right: 0;
}
.week-container .time_header{
	overflow: hidden;
	padding:0 30px;
}
.week-container .time_header h3{
	width:14.1%;
	text-align: center;
	margin:0;
	line-height: 40px;
	float: left;
	font-weight: 600;
	font-size: 16px;
}
.week-container .time_con{
	overflow: hidden;
	width: 300%;
	margin-left: -100%;
}
.week-container .time .slider_li{
	float: left;
	width:33.3%;
	padding:0 30px;
	box-sizing: border-box;
}
.week-container .time_td{
	float: left;
	width:14.1%;
	height:40px;
	text-align: center;
	border-radius: 50%;
	position: relative;
}
.week-container .time_td p{
	margin:0;
}
.week-container .selected{
	background: #eee;
}
.week-container .c
之前在网上想找一个简单易用的周日选择插件,发现这种前端周日插件很少,而且很多文章写的的算法都不是统一的,所以自己实现了一个基于jquery的周日插件(还支持跳转到指定年份和哦)。 插件的算法:每周日为起始,第一以每年第一个星期四所在的为第一(网上找的好像这个算法比较正规) 实现的效果是在手机端,也可以在PC端用,毕竟功能才是主要的。如果觉得样式不入眼可以自行随意修改。 //调用周日方法 var weekfn = new jcalendar_week({ element: "#jcalendar_week",//填充日的dom元素 dayaddclass:function(date){ //添加某天时给添加类名(参数:1.日期)(返回类名字符串,多个以空格分开) return ""; }, dayclick:function(date,obj){ //day点击事件(参数:1.日期,2.所点击DOM元素) $(obj).addClass("calendar_day_act").siblings().removeClass("calendar_day_act"); } }); 点击上方显示当前年份和的DOM部分可选择并跳转到指定年份和插件提供的方法: //获取第一天方法weekfirstdate(),传入年份和数 console.log(weekfn.weekfirstdate(2018,36)); //获取传入日期为当年第几getweeknum(),传入年,月,日(注:这里的月份从0开始) console.log(weekfn.getweeknum(2018,0,16)); //跳转到指定confirmweek(),传入年份和数 weekfn.confirmweek(getyear,getweek); //跳转到本nowweek() weekfn.nowweek();
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值