게시물 내용
ㄴㄴ
- 작성자
- 전체관리자
- 작성일
- 2026.04.01
- 조회수
- 14
function toggleSelectBox(departId, boxId) {
const btn = document.querySelector(`#${departId} a`);
const box = document.getElementById(boxId);
const isOpen = box.style.display === "block"; // 현재 열림 상태 확인
if (isOpen) {
// 닫기
box.style.display = "none";
btn.setAttribute("aria-expanded", "false");
} else {
// 열기
box.style.display = "block";
btn.setAttribute("aria-expanded", "true");
}
}
// 닫기 버튼용 (X 버튼 클릭)
function closeSelectBox(departId, boxId) {
const btn = document.querySelector(`#${departId} a`);
const box = document.getElementById(boxId);
box.style.display = "none";
btn.setAttribute("aria-expanded", "false");
btn.focus(); // 스크린리더 포커스용
}
// 키보드 접근성 (Enter / Space)
document.querySelectorAll("#select_depart1 a, #select_depart2 a").forEach(btn => {
btn.addEventListener("keydown", (e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
const departId = btn.parentElement.parentElement.id;
const boxId = btn.getAttribute("href").replace("#","");
toggleSelectBox(departId, boxId);
}
});
});
const btn = document.querySelector(`#${departId} a`);
const box = document.getElementById(boxId);
const isOpen = box.style.display === "block"; // 현재 열림 상태 확인
if (isOpen) {
// 닫기
box.style.display = "none";
btn.setAttribute("aria-expanded", "false");
} else {
// 열기
box.style.display = "block";
btn.setAttribute("aria-expanded", "true");
}
}
// 닫기 버튼용 (X 버튼 클릭)
function closeSelectBox(departId, boxId) {
const btn = document.querySelector(`#${departId} a`);
const box = document.getElementById(boxId);
box.style.display = "none";
btn.setAttribute("aria-expanded", "false");
btn.focus(); // 스크린리더 포커스용
}
// 키보드 접근성 (Enter / Space)
document.querySelectorAll("#select_depart1 a, #select_depart2 a").forEach(btn => {
btn.addEventListener("keydown", (e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
const departId = btn.parentElement.parentElement.id;
const boxId = btn.getAttribute("href").replace("#","");
toggleSelectBox(departId, boxId);
}
});
});
















