Realization of short-message button countdown (super Simple) _javascript technique based on javascript

Source: Internet
Author: User

Taobao and other shopping sites, we will see a message to send the Countdown button, on Earth is how to achieve it? Below I will give you a piece of code is very practical.

Nonsense not much said, directly to everyone paste JS code.

 * *
 120 seconds Mobile phone Short message button Countdown
 /exports.sendmessage = function (name) {
  var second =;
  $ (name). attr ("Disabled", true);
  var color = $ (name). CSS (' Background-color ');
  $ (name). attr ("style", "Background-color: #c1c1c1");
  function Update (num) {
   if (num = = second) {
    $ (name). attr ("style", "Background-color:" +color);
    $ (name). Text ("Get Validation Code");
    $ (name). attr ("disabled", false);
   else {
    var printnr = second-num;
    $ (name). Text (Printnr + seconds to get);
   }
  function Uupdate (i) {return
   function () {
    update (i);
   }
  }
  for (var i = 1; I <= second i++) {
   settimeout (uupdate (i), I * 1000);
  }
 

The above code is this article for you to introduce the JavaScript implementation of mobile phone Short message button countdown all narrative, I hope you like.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.