Use JS to implement button control text box plus 1 minus 1 applied to hours + minutes

Source: Internet
Author: User

  Just as the title says use JS to implement button control text box plus 1 minus 1, this class is mainly used in hours + minutes, below a good example, like friends can refer to the following

Time.html code:  Code as follows: <!doctype html>  <html lang= "en" >  <head>  <meta charset= "UTF-8" >  <meta name= "generator" content= "editplus®" >  <meta name= "Author" content= "" >   <meta name= "Keywords" content= ">  <meta name=" Description "content=" ">  <title> document</title>  <script type= "Text/javascript" src= "Jquery-1.8.2.min.js" ></script>  <script type= "Text/javascript" src= "time.js" ></script>  </head>  <body>  <input type= "button" value= "Hour Plus" onclick= "add_hour ();" >  <input type= "text" value= "id=" Hour ">  <input type=" button "value=" Hour minus "onclick=" Sub_hour ( );" >  <br/>  <br/>  <input type= "button" value= "Minute Plus" onclick= "Add_minute ();" >  <input type= "text" value= "id=" minute ">  <input type=" button "value=" minutes minus "onclick=" sub_ Minute (); " >  </body>  </html>    time.js code:  code as follows: function Add_num (a,b,c) {    if (c<a) {  c+ +; }  else{  c=b; }  if (c<=9&&c>=0) {  c= "0" +c; }  return c;& nbsp }  function Sub_num (a,b,c) {  if (c>a) {  c--; }  else{  c=b; }  if (c<=9& amp;&c>=0) {  c= "0" +c; }  return c; }  function add_hour () {  var current_num=$ ("# Hour "). attr (" value ");  current_num=add_num (23,0,current_num);  $ (" #hour "). attr (" value ", current_num);  }  function Sub_hour () {  var current_num=$ ("#hour"). attr ("value");  Current_num=sub_num (0,23, Current_num);  $ ("#hour"). attr ("value", current_num); }  function Add_minute () {  var current_num =$ ("#minute"). attr ("value");  current_num=add_num (59,0,current_num);  $ ("#minute"). attr ("value", Current_num); }  function Sub_minute () {  var current_num=$("#minute"). attr ("value");  current_num=sub_num (0,59,current_num);  $ ("#minute"). attr ("value", Current_ num); } 

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.