JavaScript shopping cart development tutorial with perfect functions
In the previous 2 sections, we have added and subtracted the shopping cart, and the function of changing the total price has been completed, but there are still some small problems.
If I enter text in the text box, in English, we will It needs to be processed
Friends, think about it, enter content in the text box, when our mouse leaves the text box, a loss of focus event will be triggered. Next, we will use onblur to handle this. Loss of focus event,
If we enter a number, then the total price also needs to be calculated based on the number we enter.
Let’s write the loss of focus event. The code is as follows:
名称 | 单价 | 数量 | 总价 |
---|---|---|---|
手表 | 1999 | - + | 1999 |