project_0416

ooohyooo·2024년 4월 16일

myproject

목록 보기
38/44
  • 문제 발생) $(".reservationdate").each(function() {} 가 실행되지 않음

    • DOM이 준비되지 않음: 스크립트가 실행될 때 jQuery로 선택하려는 DOM 요소를 사용할 수 있는지 확인하세요. DOM이 완전히 로드되었을 때만 실행되도록 jQuery 코드를 $(document).ready() 함수 안에 래핑하세요.
  • function displayCalendar(date, schedules) {}

 const gamelist = []; // game Date형 배열
  	  const gameMinuslist = []; // game5일전 Date형 배열

  	  for(let i = 0; i < gameDates.length; i++){

            const [monthStr, dayStr] = gameDates[i].split('.'); 
            
            const month = parseInt(monthStr, 10);
            const day = parseInt(dayStr, 10);
            
            const gamelistDate = new Date(currentDate.getFullYear(), month - 1, day);

            gamelist.push(gamelistDate);
            //console.log("!!!" + gamelist[35]);
            const gameMinusDate = new Date(currentDate.getFullYear(), gamelistDate.getMonth(), (gamelistDate.getDate()-4));
            
            gameMinuslist.push(gameMinusDate);
            //console.log("@@@" + gameMinuslist[35]);
  	  }
  	
      $(".reservationdate").each(
  			function() {

  				// 클래스이름을 조회해서 split
 					var classes = $(this).attr("class").split(" ");
 					
 					const thisdate = classes[1];
 					
     				const [yearStr, monthStr, dayStr] = thisdate.split('-'); 
 			          
     			 	  const year = parseInt(yearStr, 10); //parseInt(string, radix(진수)) 문자열 분석하고 정수로 변환
			          const month = parseInt(monthStr, 10);
			          const day = parseInt(dayStr, 10);
			          
 			          const thisday = new Date(year, month - 1, day); // 현재 날짜 Data
 			         // console.log("thisday: " + thisday);
			    	 	
/*  			       	 if (isGameToday(thisday, allDatesOfMonth, gameDates) === thisday) {
 			       		console.log("thisday: " + thisday);
 			    	 	 */
 			       		for(let i = 0; i <= gamelist.length; i++){
 			    	 		
  			        	  if(thisday <= gamelist[i] && thisday >= gameMinuslist[i]){
  			        		
  			        		  console.log("gamelist[i]: " + gamelist[i]);
  			        		 console.log("gameMinuslist[i]: " + gameMinuslist[i]);
  			        		 $(this).css("background-color", "pink");
  			        	  }
  			          }
 			       /*  } */      
 			});
        
	}

  • 캘린더 결합형 막대 찾아보래....api가 있다는데....?

0개의 댓글