html页面:

<div class="recordbriefing-title-top-body">
<span class="record-left"></span>
<p class="record-Ptime"></p>
<span class="record-right"></span>
</div>

css样式:

.record-left{
content: "";
width: 0;
height: 0;
float: left;
border-top: 10px solid transparent;
border-right: 10px solid red;
border-bottom: 10px solid transparent;
margin-top:5px;
}
.record-right{
content: "";
width: 0;
height: 0;
float: right;
border-top: 10px solid transparent;
border-left: 10px solid red;
border-bottom: 10px solid transparent;
margin-top:5px;
margin-right: 25px;
}
.record-Ptime{
display:inline-block;
width: 80%;
font-size: 16px;
color: #000;
text-align: center;
line-height: 31px;
}

js部分:

$(function() {
var rsValue='';
var todayData=new Date();
var year= todayData.getFullYear();
var month= todayData.getMonth();//月份从0开始
// console.log(typeof month);
var day=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var todayDay;

for(var i=0;i<day.length;i++){
if(i==month){
todayDay=day[i];
}
if((year%4)==0){
if((month+1)==2){
todayDay=29;
}
}
}

if(month>9){
rsValue=year+'.'+(month+1)+'.01~'+year+'.'+(month+1)+'.'+todayDay;
}else{
rsValue=year+'.0'+(month+1)+'.01~'+year+'.0'+(month+1)+'.'+todayDay;
}
// console.log(rsValue);
// 得到的拼接时间显示在页面上
$(".record-Ptime").empty();
$('.record-Ptime').append(rsValue);
changeTime();

// 上个月 左边改变时间事件
var j=1;
$(".record-left").on("click", function(){
j--;

// 判断月份是否>0,是13时就年份加1
if((month+j)<=0){
year-=1;
month=11;
j=1;
}
for(var i=0;i<day.length;i++){
if(i==(month+j-1)){
todayDay=day[i];
}
if((year%4)==0){
if((month+j)==2){
todayDay=29;
}
}
}
if((month+j)>9){
rsValue=year+'.'+(month+j)+'.01~'+year+'.'+(month+j)+'.'+todayDay;
}else{
rsValue=year+'.0'+(month+j)+'.01~'+year+'.0'+(month+j)+'.'+todayDay;
}
// 得到的拼接时间显示在页面上
$(".record-Ptime").empty();
$('.record-Ptime').append(rsValue);
changeTime();

});

// 下个月 右边改变时间事件
$(".record-right").on("click", function(){
j++;

// 判断月份是否>12,是13时就年份加1
if((month+j)>12){
year+=1;
month=0;
j=1;
}
for(var i=0;i<day.length;i++){
if(i==(month+j-1)){
todayDay=day[i];
}
if((year%4)==0){
if((month+j)==2){
todayDay=29;
}
}
}
if((month+j)>9){
rsValue=year+'.'+(month+j)+'.01~'+year+'.'+(month+j)+'.'+todayDay;
}else{
rsValue=year+'.0'+(month+j)+'.01~'+year+'.0'+(month+j)+'.'+todayDay;
}
// 得到的拼接时间显示在页面上
$(".record-Ptime").empty();
$('.record-Ptime').append(rsValue);
changeTime();
});

});

最新文章

  1. XVI Open Cup named after E.V. Pankratiev. GP of Ekaterinburg
  2. NOIP 考前 高斯消元练习
  3. C#之延迟加载
  4. 【Ext.Net学习笔记】05:Ext.Net GridPanel的用法(包含Filter、Sorter、Grouping、汇总(Summary)的用法)
  5. 让Laravel5支持memcache的方法
  6. RH033读书笔记(9)-Lab 10 Understanding the Configuration Tools
  7. Hadoop集群搭建的密钥配置SSH实现机制
  8. salesforce 零基础学习(六十八)http callout test class写法
  9. if中可以使用那些作为判断条件呢?
  10. CART决策树和随机森林
  11. 苹果中国全系降价:iphone最高降500元,用户可退差价
  12. 软件工程启程篇章:结对编程和进阶四则运算(197 &amp; 199)
  13. Flink - Scheduler
  14. iOS UI进阶-6.0 手势
  15. Cross-site request forgery 跨站请求伪造
  16. Java&#160;java&#160;jdk在Linux下安装与环境变量的配置
  17. Scramble String leetcode java
  18. Linux抓包工具
  19. Oracle 学习之exists
  20. git忽略操作

热门文章

  1. Halcon17无法加载&quot;hdevenginecpp&quot;:找不到指定的模块
  2. PAT——乙级1006:换个格式输出整数&amp;乙级1021:个位数统计&amp;乙级1031:查验身份证
  3. MyBatis实例教程--开发环境搭建
  4. 【Python】python中的__dict__,__getattr__,__setattr__
  5. Java语言课程设计
  6. 【Linux】Linux修改openfile和max user processes?
  7. 玩转VFS(二)
  8. JSP动作标识
  9. log4net将日志写入ElasticSearch
  10. hdu 1695 GCD (欧拉函数+容斥原理)