질문의 ID를 가진 h3을 인쇄하려고하는데 작동하지 않습니다. JavaScript - document.write not working
function questions() {
var question = document.getElementById("question");
document.write(question);
}
questions();
body {
font-family: Arial;
}
.header {
padding-top: 50px;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="header">
<h1>Edu Game 1</h1>
<h3>What is<h3 id="question">1+1?</h3></h3>
<input type = "text" id="ansBox" />
</div>
<script src="scripts.js"></script>
</body>
</html>
당신이 볼 수 있듯이 그것은 자바 스크립트에 도달 할 때까지, 결과가 괜찮
. 이 문제를 어떻게 해결할 수 있습니까? document.write는 물건을 인쇄 할 때 가장 좋은 방법이 아니라는 것을 압니다.
와우. 너는 나랑 같은 이름이야. 우리는 관련이 있습니까? –
'document.getElementById ("question")'가 돌아오고 당신은 무엇을 표시하기를 희망합니까? 'document.write'는 거의 올바른 방법이 아닙니다. – j08691
h3의 텍스트 인 1 + 1을 인쇄하고 싶습니다. –