Javascript development ideas and adjustment code for audio calculator

In the first two sections, we introduced the practice of HTML pages and JavaScript developed by calculators. Below we will explain the ideas and other things to pay attention to based on the previous practice.

The idea is actually very simple, because there is no relevant logic involved, so just do the functions according to the needs, mainly the click event.

First of all, there is nothing to say about the html page. There is no logic in it. It is basically the layout. It depends on the degree of mastery of HTML+CSS. Just practice more. What I want to mention here is <input type="text" value="0" onfocus="this.blur();" id="result"/>, onfocus=this.blur() in this line of code The function of the code is to make keyboard input impossible. Because it is an input form and type="text", we can also input using the keyboard, not only numbers, but also letters and symbols. This is inconsistent with the function of the calculator, so to prevent this situation, we will use the keyboard The input is limited, so the code onfocus=this.blur() is used.

The next step is JavaScript code. We can all think of basic click events, such as numbers and symbols, and it is not very difficult to write without too much logic. Mainly, there are some small problems. Small bugs need to be debugged, such as the decimal point. I didn’t pay attention to it when I started to do it. The decimal point can be clicked many times, but the actual calculator does not work, so it needs to be modified. A function is not finished when it is completed. It is also necessary to constantly look for loopholes in the function and then optimize it. This may be the most difficult thing.


Continuing Learning
||
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> </body> </html>
submitReset Code