1jq的效果代码

//全局变量用于存储当前时间
var nows; function rightZeroStr(v) {
if (v < ) {
return "" + v;
}
return v + "";
}
//计时 每10秒中为当前时间+10
setInterval(function () {
nows =parseInt(nows) + ;
}, );
//ajax.post 向服务器请求得到当前的服务器时间
function syncTime() {
var url = "Handler/Seckil.ashx?t=" + new Date().getTime();
$.post(url, { action: "now" }, function (response) {
nows = response.nows || new Date().getTime();
});
}
//倒计时 参数arg存放倒计时的标签名称 id 或者class
function lxfEndtime(arg) {
$(arg).each(function () {
var lxfday = $(this).attr("lxfday"); //用来判断是否显示天数的变量
var endtime = new Date($(this).attr("endtime")).getTime(); //取结束日期(毫秒值)
var nowtime = nows; //今天的日期(毫秒值)
var starttime = new Date($(this).attr("starttime")).getTime();
//开始时间和当时时间作比较 判断是开始 技术还是正在进行中
if (starttime >= nowtime) {
$(this).html("活动即将开始")
}
if (endtime <= nowtime) {
$(this).html("活动已经结束"); //如果结束日期小于当前日期就提示过期啦
}
if (starttime < nowtime && endtime > nowtime) {
var youtime = endtime - nowtime; //还有多久(毫秒值)
var seconds = youtime / ;
var minutes = Math.floor(seconds / );
var hours = Math.floor(minutes / );
var days = Math.floor(hours / );
var CDay = days;
var CHour = CDay * + hours % ;
var CMinute = minutes % ;
var CSecond = Math.floor(seconds % ); //"%"是取余运算,可以理解为60进一后取余数,然后只要余数。 if ($(this).attr("lxfday") == "no") {
$(this).html('<span class="countdown" millseconds="1188163453"> <strong class="tcd-h">' + CHour + '</strong>时<strong class="tcd-m">' + CMinute + '</strong>分 <strong class="tcd-s">' + CSecond + '</strong>秒 </span>'); //输出没有天数的数据
} else {
$(this).html('<span class="countdown" millseconds="1188163453"><strong class="tcd-d">' + days + '</strong><b>天</b> <strong class="tcd-h">' + CHour + '</strong> <i>:</i> <strong class="tcd-m">' + CMinute + '</strong><i>:</i> <strong class="tcd-s">' + CSecond + '</strong> </span>'); //输出有天数的数据
}
}
});
setTimeout("lxfEndtime('" + arg + "')", );
};

2用到的handler

<%@ WebHandler Language="C#" Class="Seckil" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Data;
public class Seckil : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/json";
string action = context.Request["action"];
switch (action)
{case "now":
now(context);
return; }
context.Response.Write("Hello World");
}public void now(HttpContext context)
{
Int64 retval = ;
DateTime st = new DateTime(, , );
TimeSpan t = (DateTime.Now.ToUniversalTime() - st);
retval = (Int64)(t.TotalMilliseconds + 0.5);
context.Response.Write("{\"nows\":\"" + retval + "\"}");
} public bool IsReusable
{
get
{
return false;
}
} }

3前台页面代码

<html>
<script src="js/time.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
syncTime();
lxfEndtime(".box font");
});
</script>
<body>
<font color=\"#FF0000\" endtime=\"' + dataitem.EndDate + '\" starttime=\"' + dataitem.StartDate + '\" lxfday=\"no\"></font>
</body>
</html>

jq实现竞拍倒计时的更多相关文章

  1. js&jq 发送验证码倒计时

    <input  type="text"   name=''  id="btn"> //发送验证码倒计时var wait=30; function t ...

  2. destoon开发笔记-JQ+JS实现倒计时功能

    页面代码 <div class="time " class="" id="onBidtime125" pid="125&qu ...

  3. JS与JQ倒计时的写法

    页面需要制作一个倒计时的功能:然后度娘了一遍,找到两种写法,原生JS与JQ 的,经过测试原生JS在IE可能会有不刷新的现象所以结合了一个大神的JQ写法修改好了一个. 原生JS写法: HTML: < ...

  4. jq 倒计时

    引入jq 注 在IE和safari 如果时间出现NAN 将时间格式改为YYYY/MM/DD HH:MM:SS 例:var d2 = new Date("2019/02/18 15:59&qu ...

  5. jq倒计时(代码)

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  6. jq 实现发送验证码倒计时功能

    var util = { wait:60, hsTime: function (that) { _this = this; if (_this.wait == 0) { $('#hsbtn').rem ...

  7. jQ效果:jQuery之插件开发短信发送倒计时功能

    实现的主要功能如下: 1.点击按钮的时候,可以进行倒计时,倒计时自定义. 2.当接收短信失败后,倒计时停止,可点击重新发送短信. 3.点击的元素支持一般标签和input标签. html代码: < ...

  8. js,JQ获取短信验证码倒计时

    按钮 <a href="javasript:void(0);"onclick="settime(this);">获取手机验证码</a> ...

  9. jq 某个时间段的倒计时

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. IOS SQLITE 数据库操作

    NSArray * array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); N ...

  2. ping命令的几个简单使用

    发觉linux下的ping命令花样还挺多的,下面是几个例子 1.ping www.baidu.com,最粗糙的用法,此时主机将不停地向目的地址发送ICMP echo request数据包,直至你按下C ...

  3. [Hive - Tutorial] Data Units 数据存储单位

    Data Units In the order of granularity - Hive data is organized into: 数据库.表.分区.桶 Databases: Namespac ...

  4. 关于python的import

    在软件包里,必须添加__init__.py文件. 想要对外公开的module必须在__init__.py内import一次,这样这些module才能被外部代码import并调用.

  5. 修改 jquery easyui 表单验证默认的样式

    目前对于不符合要求的输入域会在右侧显示一个带箭头的提示,可是如果我的输入框比较靠右的话就显示不全了(虽然会出滚动条,但是由于鼠标移开就消失了,所以还是看不到提示内容)! 能不能把这个提示的位置改变一下 ...

  6. Delphi使用TStringHash实现建立类(有点像反射)

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  7. CodeForces 455A Boredom (DP)

    Boredom 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/G Description Alex doesn't like b ...

  8. CodeForces 682B Alyona and Mex (排序+离散化)

    Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave ...

  9. eclipse中如何设置tomcat启动时间

    现象:在eclipse中启动tomcat总是提示“Server Tomcat v5.5 Server @ localhost was unable to start within 45 seconds ...

  10. uniPanel特效

    function beforeInit(sender){ sender.layout='accordion'; Ext.apply (sender, {title:'供应链',style:'text- ...