Home > Article > Web Front-end > How to use jQuery to increment and decrement input values_jquery
The example in this article describes how to use jQuery to implement increment and decrement of input values. Share it with everyone for your reference. The specific analysis is as follows:
In many e-commerce websites, when it comes to the quantity of goods on the page where the shopping cart is located, a button and - button will be provided to increase and decrease by 1, and only allow numerical values to be entered in the input. The Bootstrap TouchSpin plug-in is written to meet this need. (Click here to download the Bootstrap TouchSpin plug-in from this site .)
First introduce the necessary css and js files.
1. Control the accuracy and automatic increment and decrement of numerical values
● Click the number button to increase it by 0.1 ● Click the - button to decrease the value by 0.1
● Keep 2 decimal places
● Minimum allowed value 0.00
● Maximum allowed value 100.00
● Only numerical values are allowed to be entered, otherwise the focus will be lost and the minimum value will be displayed as 0.00
2. Only integers starting from 1 are allowed, which is also a common practice on shopping cart pages