project_0319 모달 오류 수정

ooohyooo·2024년 3월 19일

myproject

목록 보기
23/44
    /* function isGameToday(currentDate, allDatesOfMonth, gameDates) {
    
        for (let i = 0; i < gameDates.length; i++) {
            const formattedCurrentDate = getFormattedDate(allDatesOfMonth[i]);
            if (gameDates.includes(formattedCurrentDate)) {
                return formattedCurrentDate;
            }
        }
    } */실패작
    
    function isGameToday(currentDate, allDatesOfMonth, gameDates) {
        const formattedCurrentDate = getFormattedDate(currentDate);
        return gameDates.includes(formattedCurrentDate);
    }
    
/* 모달 기능 */
    function openModal(id) {
	
    	var zIndex = 999;
        const modal = document.getElementById(id);
        const selectedDateElement = document.getElementById("modal-content");
        
     // 모달 div 뒤에 희끄무레한 레이어
        var bg = document.createElement('div');
        bg.className = 'modal_bg'; // 클래스 추가
        bg.setStyle({
            position: 'fixed',
            zIndex: zIndex,
            left: '0px',
            top: '0px',
            width: '100%',
            height: '100%',
            overflow: 'auto',
            // 레이어 색갈은 여기서 바꾸면 됨
            backgroundColor: 'rgba(0,0,0,0.3)'
        });
        document.body.append(bg); // 배경 레이어를 body에 추가

        // 닫기 버튼 처리, 시꺼먼 레이어와 모달 div 지우기
       modal.querySelector('.modal_close_btn').addEventListener('click', function() {
		    bg.remove();
		    modal.style.display = 'none';
		});
        
       modal.setStyle({
           position: 'fixed',
           display: 'block',
           boxShadow: '0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)',
           // 시꺼먼 레이어 보다 한칸 위에 보이기
           zIndex: 10000,
	
           // div center 정렬
           top: '50%',
           left: '50%',
           transform: 'translate(-50%, -50%)',
           msTransform: 'translate(-50%, -50%)',
           webkitTransform: 'translate(-50%, -50%)'
       });
    }
    
  • 아 나 바보인가 const modal = document.getElementById(id); 이거 파라미터 이상하게 넘겨줘서 모달이 안나온거였자나...?;;

0개의 댓글