亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js與jQuery實(shí)現(xiàn)的用戶注冊(cè)協(xié)議倒計(jì)時(shí)功能實(shí)例【三種方法】

 更新時(shí)間:2017年11月09日 09:52:43   作者:無(wú)鹽海  
這篇文章主要介紹了js與jQuery實(shí)現(xiàn)的用戶注冊(cè)協(xié)議倒計(jì)時(shí)功能,結(jié)合實(shí)例形式分析了三種倒計(jì)時(shí)功能的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了js與jQuery實(shí)現(xiàn)的用戶注冊(cè)協(xié)議倒計(jì)時(shí)功能。分享給大家供大家參考,具體如下:

方法一:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>chabaoo.cn 注冊(cè)倒計(jì)時(shí)</title>
  <script type="text/javascript">
    //用戶有十秒鐘的時(shí)間看協(xié)議,超過(guò)十秒鐘,“同意”按鈕將生效
    var Seconds = 10;
    //計(jì)時(shí)器ID
    var setIntervalID;
    function ok() {
      var getid = document.getElementById("but");
      if (Seconds <= 0) {
        getid.value="同意";
        getid.disabled = false; //或者寫成getid.disabled=""; 啟用getid控件。
        //停止計(jì)時(shí)器
        clearInterval(setIntervalID);
      }
      else {
        getid.value = "請(qǐng)仔細(xì)閱讀協(xié)議還剩下【" + Seconds + "】秒";
      }
      Seconds--;
    }
   setIntervalID=setInterval("ok()", 1000);
  </script>
</head>
<body>
<textarea cols="20" rows="8"></textarea><br />
<!--disabled="disabled" 默認(rèn)submit表單是禁用的,也就是只讀的,不能點(diǎn)擊-->
<input type="submit" id ="but" value="同意" disabled="disabled" />
</body>
</html>

運(yùn)行效果:

方法二:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>chabaoo.cn 注冊(cè)倒計(jì)時(shí)</title>
  <script src="jquery-1.7.2.min.js"></script>
</head>
<body>
  <form action="http://chabaoo.cn/" method="post" name="agree">
    <input type="submit" class="button" value="" name="agreeb">
  </form>
</body>
</html>
<script>
  var secs = 5;
  var si;
  $(function () {
    $(".button").attr("disabled", "disabled");
    $(".button").val("請(qǐng)認(rèn)真查看<服務(wù)條款和聲明>(" + secs + ")")
    si = setInterval(a, 1000);
  })
  function a() {
    $(".button").val("請(qǐng)認(rèn)真查看<服務(wù)條款和聲明>(" + (secs-1) + ")");
    if (secs == 0) {
      clearInterval(si);
      $(".button").val("我同意" ).removeAttr("disabled");
    }
    secs--;
  }
</script>

運(yùn)行效果:

方法三:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>chabaoo.cn 注冊(cè)倒計(jì)時(shí)</title>
</head>
<body>
  <form action="http://chabaoo.cn/" method="post" name="agree">
    <input type="submit" class="button" value="請(qǐng)認(rèn)真查看<服務(wù)條款和聲明> (30)" name="agreeb">
  </form>
</body>
</html>
<script>
  var secs = 30;
  document.agree.agreeb.disabled = true;
  for (var i = 1; i <= secs; i++) {
    window.setTimeout("update(" + i + ")", i * 1000);
  }
  function update(num) {
    if (num == secs) {
      document.agree.agreeb.value = " 我 同 意 ";
      document.agree.agreeb.disabled = false;
    }
    else {
      var printnr = secs - num;
      document.agree.agreeb.value = "請(qǐng)認(rèn)真查看<服務(wù)條款和聲明> (" + printnr + ")";
    }
  }
</script>

運(yùn)行效果:

PS:這里再為大家推薦幾款時(shí)間及日期相關(guān)工具供大家參考使用:

在線秒表工具:
http://tools.jb51.net/bianmin/miaobiao

在線日期/天數(shù)計(jì)算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi

在線日期天數(shù)差計(jì)算器:
http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix時(shí)間戳(timestamp)轉(zhuǎn)換工具:
http://tools.jb51.net/code/unixtime

更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript時(shí)間與日期操作技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論