Clips Front End JS Countdown button to get verification code

Source: Internet
Author: User

1 <ahref= "javascript:void (0);"onclick= "Get_captcha ()"class= "btn btn-default btn6"ID= "For_captcha" >Get Verification Code</a>2 3 <Scripttype= "Text/javascript">4  5 varURL="/get-verify-code?phone_number=";6 vari;7           8 functionCount_down () {9 I=I-1;Ten       $('#for_captcha'). attr ('Disabled','Disabled'); One       $('#for_captcha'). HTML ('remaining'+I+'seconds.'); A       if(i<=0){ -       $('#for_captcha'). Removeattr ('Disabled','Disabled'); -       $('#for_captcha'). HTML ('Get Verification Code'); the Window.cleartimeout (countdown); -        } -        Else{ -                 varCountdown=SetTimeout ('Count_down ()', +); +        }               - } +  A functionGet_captcha () { at     varPhone= $('#phone'). Val ();//Console.log (phone); - URL=URL+phone;  -  - Re= /^1\d{10}$/;  -      if(Re.test (phone)) { - $.post (URL,function(data) { in Console.log (date); - }). Complete (function(){ to Console.log (' Complete'); +              }); -  the I= -; * Count_down (); $       }Panax Notoginseng       Else { - Alert ("phone number is not correct"); the              return false; +       } A  the  } + </Script>

Note

Project using bootstrap, when I wrote this script, I found a very strange phenomenon, the click on the button to get the instant button disappeared

There's a moment in Firefox and Chrome, but just a little touch of any page element or even just a F12 for an element review,

Everything's fine.

I found that when the disabled position became relative, and normally it was static but the problem was not here because of the predefined style of bootstrap

BTN Btn-default in the blink of an application the priority weight exceeds one of my defined background-color:white which causes the illusion of coverage and button disappearance, which should not have happened.

Because touching any page element, the browser recalculates, applying my definition style

I still can't find the direct reason that he covers my style, so I use Background-color first: #218e23!important; resolve this problem.

Clips Front End JS Countdown button to get verification code

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.