• jQuery,月历,左右点击事件实现月份的改变


    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: "";
    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: "";
    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;
    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();
    });

    });

  • 相关阅读:
    docker学习笔记3:镜像操作(查找和下载)
    docker学习笔记2:容器操作
    docker学习笔记1:docke环境的查看
    CSS鼠标样式
    Ubuntu下安装和配置mysql
    HR函数学习01——创建组织单位
    SAP模块常用增强总结{转载}
    SAP物料批次管理配置及操作手册(轉載)
    交货单开票
    ABAP之PINYING拼音
  • 原文地址:https://www.cnblogs.com/xzzzys/p/7428134.html
Copyright © 2020-2023  润新知