Javascript Variable Speed addition function implementation code

Source: Internet
Author: User

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

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.