You can click a button to add 1 to the number, and click another button to Reduce the number by 1. If you hold down the button, the value of the text box increases or decreases faster, that is, the variable speed addition function.
For example, if you open the "time and date attributes" window on your computer, you can adjust the time by pressing the up and down buttons marked in the red box, and try to click and hold the mouse, you will find that its functions are the same as what I said (the accuracy is still different. It is faster to press the mouse and not add data, but it will not get faster and faster. My example is faster and faster, which is more suitable for providing big data ).
The code is very simple. I don't know if the implementation is not scientific enough when I add comments. If you have better suggestions, share them with me. The HTML and JavaScript code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <meta http-equiv =" content-Type "content =" text/html; charset = gb2312 "/> <title> Variable Speed addition </title> </pead> <body> <input name =" textBox "type =" text "id =" textBox "value =" 1 "/> <input name =" add "type =" button "onmousedown =" addNum. mouseDownHandle () "onmouseup =" addNum. mouseUpHandle () "id =" add "value =" add "/> press and hold the button, and the value increases faster </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Author: WebFlash
Source: http://webflash.cnblogs.com