zoukankan      html  css  js  c++  java
  • js 根据日期做星座联动,简洁

        $('#constellation').mousedown(function(){
    var constellations = new Array();
        /*  
    因本人数据库存的数据是数字,
    所以我需要返回星座来找到对应的数字,
    可根据实际情况改变
    */
          constellations['白羊座'] = "1";
    constellations['金牛座'] = "2";
    constellations['双子座'] = "3";
    constellations['巨蟹座'] = "4";
    constellations['狮子座'] = "5";
    constellations['处女座'] = "6";
    constellations['天秤座'] = "7";
    constellations['天蝎座'] = "8";
    constellations['射手座'] = "9";
    constellations['摩羯座'] = "10";
    constellations['水瓶座'] = "11";
    constellations['双鱼座'] = "12";

    var birth = $('#dateBirth').val();
    if(birth !==''){
    var m = birth.substr(5,2);
    var d = birth.substr(8,2);
    var consname = getAstro(m,d)+'座';
    $("#constellation").html('<option value="'+constellations[consname]+'">'+consname+'</option>');

    }

    })


    });
    function getAstro(m,d){

    return "魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯".substr(m*2-(d<"102123444543".charAt(m-1)- -19)*2,2);
    // return m-(d<"102223444433".charAt(m-1)- -19);
    }
  • 相关阅读:
    linq.js
    ES6入门
    Visual Studio Code之常备快捷键
    JavaScript——数组
    谈程序员的出路
    优秀博文
    多媒体封装格式详解---MP4
    音视频文件分析工具
    offsetof(s,m)解析
    GCC 提供的原子操作
  • 原文地址:https://www.cnblogs.com/xiangxu/p/5646164.html
Copyright © 2011-2022 走看看