This article mainly introduced the JS realizes the simulation calculator backspace key to delete the text effect method, involves the JavaScript string interception operation related skill, needs the friend to be possible to refer to under
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61-62 |
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Untitled document </title> <style type= text/css" > myinput{width:70px ; tf{width:220px; height:30px margin-bottom:5px; font-size:26px; Font-family:tahoma, Geneva, sans-serif; color: #fff; border:2px solid #999; Background: #000; Text-align:right; } </style> <script language= "javascript" type= "Text/javascript" > window.onload = function () {var tf = $ ("TF") ; for (Var i=0;i<11;i++) {$ (' btn ' +i). onclick = function () {if (This.value = = "." && Tf.value = "") return false; if (This.value = = "." && tf.value.indexOf (".")!=-1) return false; if (Tf.value = = "0") {if (This.value = = ".") {Tf.value + = This.value;} }else{Tf.value + = This.value;}} } $ ("Back"). onclick = FunctioN () {tf.value = Tf.value.replace (/.$/, ')}} function $ (id) {return document.getElementById (ID);} </script> </ head> <body> <input class= "TF" name= "TextField" type= "text" id= "TF" size= "a"/> <br/> CLA ss= "Myinput" type= "Submit" name= "button" id= "Btn0" value= "0"/> <input class= "myinput" type= "Submit" name= "button "Id=" BTN1 "value=" 1 "/> <input class=" myinput "type=" Submit "name=" button "id=" Btn2 "value=" 2 "/> <br/> & Lt;input class= "Myinput" type= "Submit" name= "button" id= "Btn3" value= "3"/> <input class= "myinput" type= "Submit" Name= "button" id= "Btn4" value= "4"/> <input class= "myinput" type= "Submit" name= "button" id= "Btn5" value= "5"/> & lt;br/> <input class= "myinput" type= "Submit" name= "button" id= "Btn6" value= "6",/> <input class= "Myinput" Typ E= "Submit" name= "button" id= "Btn7" value= "7" "/> <input class=" myinput "type=" Submit "name=" button "id=" Btn8 "value = "8"/> <br/> <input CLAss= "Myinput" type= "Submit" name= "button" id= "Btn9" value= "9"/> <input class= "myinput" type= "Submit" name= "button "Id=" Btn10 "value=". "/> <input class=" myinput "type=" Submit "name=" button "id=" Back "value=" backspace "/> </BODY&G T </html> |
I hope this article will help you with your JavaScript programming.
Note < > : More Wonderful tutorials please focus on Triple programming