Jquery手機傳送簡訊之後,進入倒計時狀態

來源:互聯網
上載者:User

標籤:style   class   blog   code   java   http   

在做手機網站開發的時候,難免發生意外。這時候,就是你展示人格魅力的時候啦!

下面是自己寫的一個發送驗證碼給手機之後,進入的一個倒計時的效果

js代碼,我可是連<script type="text/javascript">這種都貼出來啦!

<script type="text/javascript">        var InterValObj;         var count = 60;         var curCount;         function sendMessage() {            curCount = count;            $("#sendMessage").attr("disabled", "true");            $("#sendMessage").parent().children().first().children().text("在" + curCount + "秒之後重發");            $("#sendMessage").val("在" + curCount + "秒之後重發");            InterValObj = window.setInterval(SetRemainTime, 1000); //啟動計時器,1秒執行一次        }        //timer處理函數        function SetRemainTime() {            if (curCount == 0) {                window.clearInterval(InterValObj); //停止計時器                $("#sendMessage").removeAttr("disabled"); //啟用按鈕                $("#sendMessage").parent().children().first().children().text("重新發送");                $("#sendMessage").val("重新發送");            }            else {                curCount--;                $("#sendMessage").val("在" + curCount + "秒之後重發");                $("#sendMessage").parent().children().first().children().text("在" + curCount + "秒之後重發");            }        }</script>

 Html代碼,就一個按鈕

<input type="button" id="sendMessage" value="發送資訊" />

 當然了  你還得引用最重要的庫檔案。

<link href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" rel="stylesheet"        type="text/css"><script src="jquery的庫檔案" type="text/javascript"></script><script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>

 這都不是最重要的,重要的是 沒有引用啊~

 於是js加上一句:

$(function () {            $("#sendMessage").click(function () {                sendMessage();            })        })

最後的效果,在Google裡面如下:

點擊之後

很期待下次與大家的分享,不要問我是誰,請叫我紅領巾。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.