When doing mobile website development, it is inevitable that accidents occur. This is the time to show your charisma!
Below is a countdown effect that I wrote after sending a verification code to the phone and entering it
JS code, I am even <script type= "Text/javascript" > This all posted out!
<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 ("after" + Curcount + "seconds after"); $ ("#sendMessage"). Val ("Re-send" after "+ Curcount +" seconds); Intervalobj = Window.setinterval (setremaintime, 1000); Start timer, 1 seconds to execute}//timer handler function Setremaintime () {if (Curcount = = 0) { Window.clearinterval (Intervalobj); Stop Timer $ ("#sendMessage"). Removeattr ("Disabled"); Enable the button $ ("#sendMessage"). Parent (). Children (). First (). Children (). Text ("Resend"); $ ("#sendMessage"). Val ("Resend"); } else {curcount--; $ ("#sendMessage"). Val ("Re-send" after "+ Curcount +" seconds); $ ("#sendMessage"). Parent (). Children (). First (). ChiLdren (). Text ("Re-send after" + Curcount + "SEC"); }}</script>
HTML code, just a button
<type= "button" id= "SendMessage" value= "Send Message" />
Of course, you have to cite the most important library files.
<Linkhref= "Http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css"rel= "stylesheet"type= "Text/css"><Scriptsrc= "jquery library file"type= "Text/javascript"></Script><Scriptsrc= "Http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"type= "Text/javascript"></Script>
This is not the most important, the important is no reference AH ~
So JS plus a sentence:
$ (function () { $ ("#sendMessage"). Click (function () { sendMessage (); }) })
The final effect in Google is as follows:
After clicking
Look forward to the next time to share with you, do not ask me who, please call me red scarf.