function
funRes() {
var
val0 = document.getElementById(
'val0'
);
val1 = document.getElementById(
'val1'
res = document.getElementById(
'res'
//false, null, '', "", !val1.value
if
(val0.value ==
false
) {
val0.value = 0;
}
(!val1.value) {
val1.value = 0;
res.value = parseFloat(val0.value) + parseFloat(val1.value);
funEmpty0() {
val0.value =
''
;
funEmpty1() {
val1.value =
funReset() {
res.value =
funCSS() {
document.getElementById(
'reset'
).onclick = funReset;
ara = document.getElementsByTagName(
'input'
for
(
i=0; i<ara.length; i++) {
ara[i].style.width =
'100px'
ara[i].style.textAlign =
'center'
val = document.getElementById(
'main'
val.style.height =
val.style.width =
'600px'
val.style.position =
'absolute'
val.style.top =
'50%'
val.style.left =
val.style.marginTop =
'-50px'
val.style.marginLeft =
'-300px'
val.style.textAlign =
val.style.lineHeight =
window.onload =
() {
).oninput = funRes;
).onfocus = funEmpty0;
).onfocus = funEmpty1;
funCSS();
<!DOCTYPE html>
<
html
>
head
meta
charset
=
"utf-8"
/>
title
>New Page</
script
src
"js/script.js"
></
</
body
div
id
"main"
input
"val0"
type
"text"
label
>+</
"val1"
>=</
"res"
readonly
"readonly"
"reset"
"button"
value
"Reset"