<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>출석부 프로그램</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f4f6f8;
padding: 40px;
}
.box {
width: 420px;
margin: 0 auto;
background: #fff;
padding: 30px;
border-radius: 16px;
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
}
input {
width: 100%;
padding: 12px;
font-size: 16px;
margin-bottom: 10px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 12px;
background: #2563eb;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background: #1d4ed8;
}
ul {
margin-top: 20px;
padding-left: 20px;
}
li {
padding: 8px;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<div class="box">
<h1>출석부 프로그램</h1>
<input type="text" id="studentName" placeholder="학생 이름 입력">
<button onclick="addStudent()">학생 추가</button>
<ul id="studentList"></ul>
</div>
<script>
let students = [];
function addStudent() {
let name = document.getElementById("studentName").value;
if (name === "") {
alert("학생 이름을 입력하세요.");
return;
}
students.push(name);
document.getElementById("studentName").value = "";
showStudents();
}
function showStudents() {
let html = "";
for (let i = 0; i < students.length; i++) {
html += "<li>" + students[i] + "</li>";
}
document.getElementById("studentList").innerHTML = html;
}
</script>
</body>
</html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>출석부 프로그램</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f4f6f8;
padding: 40px;
}
.box {
width: 420px;
margin: 0 auto;
background: #fff;
padding: 30px;
border-radius: 16px;
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
h1 {
text-align: center;
}
input {
width: 100%;
padding: 12px;
font-size: 16px;
margin-bottom: 10px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 12px;
background: #2563eb;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
}
button:hover {
background: #1d4ed8;
}
ul {
margin-top: 20px;
padding-left: 20px;
}
li {
padding: 8px;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<div class="box">
<h1>출석부 프로그램</h1>
<input type="text" id="studentName" placeholder="학생 이름 입력">
<button onclick="addStudent()">학생 추가</button>
<ul id="studentList"></ul>
</div>
<script>
let students = [];
function addStudent() {
let name = document.getElementById("studentName").value;
if (name === "") {
alert("학생 이름을 입력하세요.");
return;
}
students.push(name);
document.getElementById("studentName").value = "";
showStudents();
}
function showStudents() {
let html = "";
for (let i = 0; i < students.length; i++) {
html += "<li>" + students[i] + "</li>";
}
document.getElementById("studentList").innerHTML = html;
}
</script>
</body>
</html>
#출석부 프로그램