첫 번째 섹션이 작동합니다. +를 누르면 작동합니다. + 뒤에 아무 것도 작동하지 않습니다. 플러스를 누르면 두 번째 버튼 세트가 나타나지만 아무 것도 누르지 않습니다. 그건 그렇고, 나는 계산기를 만들고있다. 어떤첫 번째 버튼이 작동하고 두 번째 버튼이 작동하지 않습니다
<html>
<head>
<title>
JavaScript
</title>
</head>
<body>
<script>
var first = ""
document.write('<button onclick="one()">1</button>');
document.write('<button onclick="two()">2</button><br/>');
document.write('<button onclick="three()">3</button>');
document.write('<button onclick="four()">4</button><br/>');
document.write('<button onclick="five()">5</button>');
document.write('<button onclick="six()">6</button><br/>');
document.write('<button onclick="seven()">7</button>');
document.write('<button onclick="eight()">8</button><br/>');
document.write('<button onclick="nine()">9</button>');
document.write('<button onclick="zero()">0</button><br/>');
document.write('<button onclick="add()">+</button><br/>');
function one(){
first = first + "1";
}
function two(){
first = first + "2";
}
function three(){
first = first + "3";
}
function four(){
first = first + "4";
}
function five(){
first = first + "5";
}
function six(){
first = first + "6";
}
function seven(){
first = first + "7";
}
function eight(){
first = first + "8";
}
function nine(){
first = first + "9";
}
function zero(){
first = first + "0";
}
function add(){
document.body.innerHTML = '';
var second = ""
document.write('<button onclick="one()">1</button>');
document.write('<button onclick="two()">2</button><br/>');
document.write('<button onclick="three()">3</button>');
document.write('<button onclick="four()">4</button><br/>');
document.write('<button onclick="five()">5</button>');
document.write('<button onclick="six()">6</button><br/>');
document.write('<button onclick="seven()">7</button>');
document.write('<button onclick="eight()">8</button><br/>');
document.write('<button onclick="nine()">9</button>');
document.write('<button onclick="zero()">0</button><br/>');
document.write('<button onclick="equal()">=</button><br/>');
function one(){
second = second + "1";
}
function two(){
second = second + "2";
}
function three(){
second = second + "3";
}
function four(){
second = second + "4";
}
function five(){
second = second + "5";
}
function six(){
second = second + "6";
}
function seven(){
second = second + "7";
}
function eight(){
second = second + "8";
}
function nine(){
second = second + "9";
}
function zero(){
second = second + "0";
}
function equal(){
first = Math.floor;
second = Math.floor;
answer = first + second;
document.write(answer);
}
}
</script>
</body>
</html>
1990 년대에는 자바 스크립트가 필요했습니다. 'document.write()'를 사용하지 말고, DOM 수정 함수를 사용하는 법을 배워라. – Barmar