The following small series will bring you a javascript simple calculator effect [recommended ]. The editor thinks it is quite good. Now I will share it with you and give you a reference for the final result, such as-2. There is a bug: The result is correct by clicking "%" after an integer, if % is clicked after the decimal point, the result is incorrect! Everything else is normal. Please advise: the input value is of the string type. In JS, how can I correct the if part in-1 ??
Figure-1
Figure 2
The HTML code is as follows:
Simple calculator @ walker
Welcome to JavaScript calculator feedback
The CSS code is as follows:
The javascript code is as follows:
Script var num = 0; // define the first input data function jsq (num) {// obtain the current input if (num = "%") {document. getElementById ('screenname '). value = Math. round (document. getElementById ('screenname '). value)/100;} else {document. getElementById ('screenname '). value + = document. getElementById (num ). value ;}} function eva () {// calculate the input result document. getElementById ("screenName "). value = eval (document. getElementById ("screenName "). value);} function clearNum () {// clear 0 document. getElementById ("screenName "). value = null; document. getElementById ("screenName "). focus ();} function tuiGe () {// return var arr = document. getElementById ("screenName"); arr. value = arr. value. substring (0, arr. value. length-1);} script
The above javascript Implementation of the simple calculator effect [recommended] is all the content shared by the small editor. I hope to give you a reference, but also hope you can support the home of foot.