HTML
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" id="modalCloseButton"></button>
자바스크립트
document.addEventListener("DOMContentLoaded", function () {
var modalOptions = {
backdrop: 'static', // background 클릭 시 모달이 꺼지지 않도록 설정
keyboard: false // ESC 키 누를 때 모달이 꺼지지 않도록 설정
};
var modalElement = document.getElementById("modal-bldsel");
var modal = new bootstrap.Modal(modalElement, modalOptions);
var closeButton = document.getElementById("modalCloseButton");
closeButton.removeAttribute("data-bs-dismiss");
closeButton.removeAttribute("aria-label");
closeButton.addEventListener("click", function () {
if (enteNmElement.textContent.trim() === '') {
alert("닫기 불가능입니다."); // 메시지 띄우기
}else{
modal.hide();
}
});
)};
반응형
'개발 > 자바스크립트 및 프론트' 카테고리의 다른 글
JSP, JS ) 네비게이션(Navigation) 탭 active 만들기 (0) | 2023.07.17 |
---|---|
자바스크립트 ) Modal 영역 밖 클릭 여부 확인 (0) | 2023.06.20 |
제이쿼리) parent 지옥에서 탈출하기, closest 사용하기 (0) | 2023.04.08 |
자바스크립트 ) ForEach에서 this 사용하기 (0) | 2023.01.27 |
(HTML) 테이블 세로 중앙 정렬 (0) | 2022.09.06 |
댓글