Solution to invalid JS time setting

Source: Internet
Author: User
When sending the short message verification code, you need to use js to set the reverse order of time. Sometimes it will cause js failure. What should I do? Today, I want to share with you a solution to the problem of invalid JS setup time. For more information, refer to the following: js setup time reverse order is required when sending the short message verification code, which sometimes leads to js failure, what should we do? Today, I will share with you how to solve the invalid JS time setting problem. For more information, see.

When sending the short message verification code, you need to use js to set the reverse order of time. Sometimes this conventional writing method will cause js to fail. You have tried many methods to find the problem, probably because the js version is too low.

setTimeout(showT(t-1),5000)

Solution:

setTimeout(function(){showT(t-1)},1000)

Or:

setTimeout("Talert(i)",5000);

Jquery code: You must use input to set the value so that jquery can be used to change the value.

<

Var t = 120; showT (t); function showT (t) {if (t> 0) {$ (". sjyzm-btn "). val (t + "Sec"); setTimeout (function () {showT (t-1)}, 1000) // setTimeout (showT (t-1), 5000) // $ ('. sjyzm-btn '). attr ("disabled", true);} else {$ (". sjyzm-btn "). val ("SMS Verification"); // $ (". sjyzm-btn "). removeAttr ("disabled ");}}

The above is a solution to the problem of invalid JS time setting described by the editor. I hope it will be helpful to you. If you have any questions, please leave a message and the editor will reply to you in time. I would like to thank you for your support for PHP chinnet!

For more articles about how to solve the invalid JS setting time, please follow the PHP Chinese network!

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.