JavaScript is a literal-translation scripting language, which is a dynamic type, a weak type, a prototype-based language, and a built-in support type. Its interpreter, known as the JavaScript engine, is widely used as a scripting language for the client, and is used in HTML (an application under the standard Universal Markup Language) to add dynamic functionality to an HTML Web page.
JavaScript consists of a ECMAScript that describes the syntax and basic objects of the language. The Document Object Model (DOM), which describes the methods and interfaces for working with Web page content. A Browser object model (BOM) that describes the methods and interfaces that interact with the browser. JavaScript features JavaScript is a web-based scripting language, has been widely used in Web application development, often used to add a variety of dynamic features for Web pages, to provide users with more smooth and beautiful browsing effect. JavaScript scripts are typically embedded in HTML to implement their own functionality.
- is an explanatory scripting language (the code is not precompiled).
- It is used primarily to add interactive behavior to HTML (an application under the standard Universal Markup Language) page.
- HTML pages can be embedded directly, but writing a separate JS file facilitates the separation of structure and behavior.
- Cross-platform features, supported by most browsers, can be run on multiple platforms (e.g. Windows, Linux, Mac, Android, iOS, etc.).
The JavaScript scripting language, like other languages, has its own basic data types, expressions and arithmetic operators, and the Basic program framework of the program. JavaScript provides four basic data types and two special data types for working with data and text. The variable provides the place where the information is stored, the expression can complete the more complex processing. Recently in the study of the next JS, a lot of fun, made a simple calculator, as follows:
Directly on the code
HTML file Code:
1 CSS style code:
1 *{2 margin:0; 3 padding:0; 4 Box-sizing:border-box; 5 font:14px arial,sans-serif; 6} 7 html{8 height:100%; 9 background-color:lightslategrey;10}11 #big {margin:15px auto;13 width:330px;14 height:470px;15 b ackground-color:darkgrey;16 border:1px solid lightgray;17 padding:15px;18}19 #top {height:20px;21}22 #tit le{23 float:left;24 line-height:30px;25}26 #author {float:right;28 line-height:30px;29}30 #import {31 Margin-top:15px;32}33 #dataname {margin-top:5px;35 width:300px;36 height:40px;37 text-align:right;38 padding-right:10px;39 font-size:20px;40}41 #key {border:1px solid lightgray;43 height:293px;44 Mar Gin-top:25px;45 padding:16px;46}47. buttons{48 float:left;49 width:52px;50 height:36px;51 text-align: center;52 background-color:lightgray;53 margin:0 18px 20px 0;54}55 buttons:hover{56 color:white;57 Background-color:blue;58}59 #bottom {margin-top:20px;61 height:20px;62 text-align:center;63}
JS Code:
1 var number = 0; Define the first input data 2 function Calc (number) {3 //Get current Input 4 if (number== "%") {5 document.getElementById (' Dataname ') ). Value=math.round (document.getElementById (' Dataname '). Value)/100; 6 }else{7 document.getElementById (' Dataname '). Value + = document.getElementById (number). value; 8 } 9}10 function Eva () {One-to-one //calculates the input result of document.getElementById ("Dataname"). Value = eval (document.getElementById (" Dataname ").}14 function Clearnum () { 16 document.getElementById (" Dataname "). Value = null;17 document.getElementById ("Dataname"). focus ();}19 function back () {+/ /backspace var arr = document.getElementById ("Dataname"); arr.value = arr.value.substring (0, arr.value.length-1); 23}
This article is for the author's opinion only, the author at the temperature of a pot of sake published. Reprint Please specify source: http://www.cnblogs.com/hong-fithing/
JavaScript Easy Calculator