Invalid js setting time

Source: Internet
Author: User

Invalid js setting time

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.

<Input type = "button" id = "sjyzm-btn" class = "sjyzm-btn" value = "get verification code"/>

 

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 ");}}

 

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.