JSP/Muzi
초마다 이미지 변경하기
미눅스[멘토]
2023. 10. 6. 21:09
728x90
var ObjectArray = []; //이미지 셋팅
ObjectArray[1] = "/resources/images/bell.png";
ObjectArray[2] = "/resources/images/bell2.png";
ObjectArray[3] = "/resources/images/bell.png";
ObjectArray[4] = "/resources/images/bell2.png";
ObjectArray[5] = "/resources/images/bell.png";
ObjectArray[6] = "/resources/images/bell2.png";
ObjectArray[7] = "/resources/images/bell.png";
ObjectArray[8] = "/resources/images/bell2.png";
ObjectArray[9] = "/resources/images/bell.png";
ObjectArray[10] = "/resources/images/bell2.png";
var nObjectCnt = 0; //count
function ShowDefaultRotate(){
nObjectCnt++; //반복하며 count 1씩증가
console.log("nObjectCnt",nObjectCnt); //잘 나오나 확인
if(nObjectCnt < ObjectArray.length){ //이미지 배열만큼 반복
document.querySelector("#newInfo").src = ObjectArray[nObjectCnt]; //이미지 넣기
obTimeOut = setTimeout("ShowDefaultRotate()",300); //1초후 자기자신 호출 //재귀호출
}else{
clearTimeout(obTimeOut);//타임아웃 중지 //끝나면 끝
nObjectCnt = 0;
}
}