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