jQuery实现根据生日计算年龄 星座 生肖_jquery

<html>
<head>
 <title></title>
 <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>

 <script type="text/javascript">
 //根据输入的生日自动获取星座,生肖和年龄。
 var year = new Array("猪", "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗");
 jQuery(function () {
  $("#Birthday").blur(function () {
  setTimeout(function () {
   var strHtml = "";
   var date = new Date($("#Birthday").val().replace(/-/g, "/"));
   var con = getxingzuo(date.getMonth() + 1, date.getDate());
   strHtml += "你的星座是:" + con;
   var zodiac = year[(parseInt(date.getFullYear()) + 9) % 12];
   strHtml += "<br/>你的生肖是:" + zodiac;
   var Age = new Date().getFullYear() - date.getFullYear();
   strHtml += "<br/>你的年龄是:" + Age;
   $("#div1").append(strHtml);
  }, 200);
  })
 })
 function getxingzuo(month, day) {
  var d = new Date(1999, month - 1, day, 0, 0, 0);
  var arr = [];
  arr.push(["魔羯座", new Date(1999, 0, 1, 0, 0, 0)])
  arr.push(["水瓶座", new Date(1999, 0, 20, 0, 0, 0)])
  arr.push(["双鱼座", new Date(1999, 1, 19, 0, 0, 0)])
  arr.push(["牡羊座", new Date(1999, 2, 21, 0, 0, 0)])
  arr.push(["金牛座", new Date(1999, 3, 21, 0, 0, 0)])
  arr.push(["双子座", new Date(1999, 4, 21, 0, 0, 0)])
  arr.push(["巨蟹座", new Date(1999, 5, 22, 0, 0, 0)])
  arr.push(["狮子座", new Date(1999, 6, 23, 0, 0, 0)])
  arr.push(["处女座", new Date(1999, 7, 23, 0, 0, 0)])
  arr.push(["天秤座", new Date(1999, 8, 23, 0, 0, 0)])
  arr.push(["天蝎座", new Date(1999, 9, 23, 0, 0, 0)])
  arr.push(["射手座", new Date(1999, 10, 22, 0, 0, 0)])
  arr.push(["魔羯座", new Date(1999, 11, 22, 0, 0, 0)])
  for (var i = arr.length - 1; i >= 0; i--) {
  if (d >= arr[i][1]) return arr[i][0];
  }
 }
 </script>
</head>
<body>
 <div id="div1" style="width:200px;height:200px;">
  <input type="text" id="Birthday" value="请输入你的生日!" />
  <input type="button" value="开始计算" />
 </div>
</body>
</html>

以上就是本文的全部内容,希望对大家有所帮助,谢谢对的支持!

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索生肖
, 生日计算年龄
星座
生肖配对星座配对、生肖星座、十二生肖星座配对、生肖星座配对查询、生肖和星座哪个准,以便于您获取更多的相关知识。

时间: 2024-08-22 14:46:31

jQuery实现根据生日计算年龄 星座 生肖_jquery的相关文章

php根据生日计算年龄的方法_php技巧

本文实例讲述了php根据生日计算年龄的方法.分享给大家供大家参考.具体如下: <?php function birthday($birthday){ $age = strtotime($birthday); if($age === false){ return false; } list($y1,$m1,$d1) = explode("-",date("Y-m-d",$age)); $now = strtotime("now"); list

php根据生日计算年龄/生肖/星座实例

//计算年龄  代码如下 复制代码 function birthday($mydate){     $birth=$mydate;     list($by,$bm,$bd)=explode('-',$birth);     $cm=date('n');     $cd=date('j');     $age=date('Y')-$by-1;     if ($cm>$bm || $cm==$bm && $cd>$bd) $age++;     return $age; //e

根据生日计算年龄的JS代码

例  代码如下 复制代码 function displayage( yr, mon, day, countunit, decimals, rounding ) {     // Starter Variables     today = new Date();     yr = parseInt(yr);     mon = parseInt(mon);     day = parseInt(day);     var one_day = 1000*60*60*24;     var one_m

php根据出生日期计算年龄 生肖 星座程序

例1  代码如下 复制代码 function getAge($birthday) {  $age = 0;  $year = $month = $day = 0;  if (is_array($birthday)) {   extract($birthday);  } else {   if (strpos($birthday, '-') !== false) {    list($year, $month, $day) = explode('-', $birthday);    $day =

如何利用JS通过身份证号获取当事人的生日、年龄、性别_javascript技巧

身份证可以识别一个人的信息,下面就介绍一下如何利用js通过身份证号码获取当事人的年龄和性别. <script> function IdCard(UUserCard,num){ if(num==1){ //获取出生日期 birth=UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14); return birth;

JS根据生日算年龄的方法

  本文实例讲述了JS根据生日算年龄的方法.分享给大家供大家参考.具体实现方法如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 function parseDate(str){ if(str.match(/^d{4}[-/s+]d{1,2}[-

JS实现根据出生年月计算年龄

 本篇文章主要是对利用JS实现根据出生年月计算年龄的示例代码进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助 代码如下: <script language=javascript>      function   ages(str)      {            var   r   =   str.match(/^(d{1,4})(-|/)(d{1,2})2(d{1,2})$/);              if(r==null)return   false;           

php计算年龄精准到年月日_php技巧

本文实例讲述了php计算年龄精准到年月日的方法.分享给大家供大家参考.具体如下: <?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ class Age { /** * 计算年龄

oracle 如何分岁/月等为单位计算年龄?

问题描述 oracle 如何分岁/月等为单位计算年龄? 有oracle一张表表中有一出生日期字段为date 类型是,现要建立一个视图 oracle 表如下 id---(varchar2(10)) date_of_birth---(date) 05576767 1957-3-28 05563743 ? ? ? ? ?2013-3-27 05563744 ? ? ? ? ?2013-7-15 05563745 ? ? ? ? ?2013-6-7 05563741? ? ? ? ? ?2010-11-