zoukankan      html  css  js  c++  java
  • js倒计时

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script src="jquery.js"></script>
    <script type="text/javascript">
    var leftSeconds = 10;//倒计时时间10秒
    var intervalId;
    $(function () {
    $("#btn_reg").attr("disabled", true);//设置按钮不可用
    intervalId = setInterval("CountDown()", 1000);//调用倒计时的方法
    });
    function CountDown() {//倒计时方法
    if (leftSeconds <= 0) {
    $("#btn_reg").val("注册"); //当时间<=0的时候改变按钮的value
    $("#btn_reg").attr("disabled", false);//如果时间<=0的时候按钮可用
    clearInterval(intervalId); //取消由 setInterval() 设置的 timeout
    return;
    }
    leftSeconds--;
    $("#btn_reg").val("请仔细阅读" + leftSeconds + "秒");
    }
    </script>
    </head>
    <body>
    <textarea cols="20" rows="8">10秒之后注册按钮才可以使用</textarea>
    <input type="button" value="注册" id="btn_reg" />
    </body>
    </html>

  • 相关阅读:
    50个网页常用小代码
    web前端题目(持续更新)
    一步步构建大型网站架构(转)
    CentOS下配置node.js
    ajax文件上传
    test
    文件上传input简便美化方案
    String.match()与RegExp.exec()
    ie7下zindex问题
    javascript将数组插入到另一个数组中
  • 原文地址:https://www.cnblogs.com/qinge/p/4554676.html
Copyright © 2011-2022 走看看