JavaScript development of shopping cart layout
First of all, we need to understand what kind of function we need to make
To make a simple shopping cart, the table has the unit price, the addition and subtraction of the quantity, and then there is a total price. When we click add or subtract, The total price will change
Let’s look at the following html layout code as follows:
名称 | 单价 | 数量 | 总价 |
---|---|---|---|
手表 | 1999 | - + | 1999 |
As shown in the above code, friends can see that there are plus and minus signs on both sides of the text box, and then friends can see The cell with id='td' has 1999 in it, which is the default value. The unit price
The cell with id="td2" is used to store the total price