<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>출석부 삭제 프로그램</title>
<style>
*{
margin:0;
padding:0;
box-sizing:border-box;
}
body{
background:#f4f6f8;
font-family:Arial, sans-serif;
padding:50px;
}
.wrap{
width:500px;
background:white;
margin:auto;
padding:30px;
border-radius:20px;
box-shadow:0 10px 30px rgba(0,0,0,0.1);
}
h1{
text-align:center;
margin-bottom:20px;
}
input{
width:100%;
padding:12px;
margin-bottom:10px;
border:1px solid #ddd;
border-radius:10px;
font-size:16px;
}
button{
padding:12px 20px;
border:none;
border-radius:10px;
background:#2563eb;
color:white;
cursor:pointer;
font-size:16px;
margin-bottom:10px;
}
button:hover{
background:#1d4ed8;
}
ul{
margin-top:20px;
}
li{
list-style:none;
background:#eee;
padding:15px;
margin-bottom:10px;
border-radius:10px;
display:flex;
justify-content:space-between;
align-items:center;
}
.deleteBtn{
background:red;
padding:8px 12px;
border-radius:8px;
color:white;
cursor:pointer;
}
</style>
</head>
<body>
<div class="wrap">
<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]}
<button
class="deleteBtn"
onclick="deleteStudent(${i})">
삭제
</button>
</li>
`;
}
document.getElementById("studentList")
.innerHTML = html;
}
// 학생 삭제
function deleteStudent(index){
students.splice(index, 1);
showStudents();
}
</script>
</body>
</html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>출석부 삭제 프로그램</title>
<style>
*{
margin:0;
padding:0;
box-sizing:border-box;
}
body{
background:#f4f6f8;
font-family:Arial, sans-serif;
padding:50px;
}
.wrap{
width:500px;
background:white;
margin:auto;
padding:30px;
border-radius:20px;
box-shadow:0 10px 30px rgba(0,0,0,0.1);
}
h1{
text-align:center;
margin-bottom:20px;
}
input{
width:100%;
padding:12px;
margin-bottom:10px;
border:1px solid #ddd;
border-radius:10px;
font-size:16px;
}
button{
padding:12px 20px;
border:none;
border-radius:10px;
background:#2563eb;
color:white;
cursor:pointer;
font-size:16px;
margin-bottom:10px;
}
button:hover{
background:#1d4ed8;
}
ul{
margin-top:20px;
}
li{
list-style:none;
background:#eee;
padding:15px;
margin-bottom:10px;
border-radius:10px;
display:flex;
justify-content:space-between;
align-items:center;
}
.deleteBtn{
background:red;
padding:8px 12px;
border-radius:8px;
color:white;
cursor:pointer;
}
</style>
</head>
<body>
<div class="wrap">
<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]}
<button
class="deleteBtn"
onclick="deleteStudent(${i})">
삭제
</button>
</li>
`;
}
document.getElementById("studentList")
.innerHTML = html;
}
// 학생 삭제
function deleteStudent(index){
students.splice(index, 1);
showStudents();
}
</script>
</body>
</html>
#출석부 삭제 프로그램