random number game-번외

장돌뱅이 ·2022년 2월 14일
0

js로 html요소 생성하기

const h1 = document.createElement("h1");
h1.innerText = "Random Number Game";
document.body.appendChild(h1);

const h2 = document.createElement("h2");
h2.innerText = "Generate a number between 0 and";
document.body.appendChild(h2);

const input1 = document.createElement("input");
input1.setAttribute("type", "number");
h2.append(input1);

const h3 = document.createElement("h3");
h3.innerText = "Guess the number";
document.body.appendChild(h3);

const input2 = document.createElement("input");
input2.setAttribute("type", "number");
h3.append(input2);

const btn = document.createElement("input");
btn.setAttribute("type", "submit");
btn.setAttribute("value", "play");
input2.after(btn);

0개의 댓글