메뉴 건너뛰기

조회 수 81532 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
function dailyMissionTimer(duration) {
    
    var timer = duration * 3600;
    var hours, minutes, seconds;
    
    var interval = setInterval(function(){
        hours	= parseInt(timer / 3600, 10);
        minutes = parseInt(timer / 60 % 60, 10);
        seconds = parseInt(timer % 60, 10);
		
        hours 	= hours < 10 ? "0" + hours : hours;
        minutes = minutes < 10 ? "0" + minutes : minutes;
        seconds = seconds < 10 ? "0" + seconds : seconds;
		
        $('#time-hour').text(hours);
        $('#time-min').text(minutes);
        $('#time-sec').text(seconds);

        if (--timer < 0) {
            timer = 0;
            clearInterval(interval);
        }
    }, 1000);
}

dailyMissionTimer(24);	// hour base


<span id="time-hour"></span>
<span id="time-min"></span>
<span id="time-sec"></span>


function countdown( elementName, minutes, seconds )
{
    var element, endTime, hours, mins, msLeft, time;

    function twoDigits( n )
    {
        return (n <= 9 ? "0" + n : n);
    }

    function updateTimer()
    {
        msLeft = endTime - (+new Date);
        if ( msLeft < 1000 ) {
            element.innerHTML = "countdown's over!";
        } else {
            time = new Date( msLeft );
            hours = time.getUTCHours();
            mins = time.getUTCMinutes();
            element.innerHTML = (hours ? hours + ':' + twoDigits( mins ) : mins) + ':' + twoDigits( time.getUTCSeconds() );
            setTimeout( updateTimer, time.getUTCMilliseconds() + 500 );
        }
    }

    element = document.getElementById( elementName );
    endTime = (+new Date) + 1000 * (60*minutes + seconds) + 500;
    updateTimer();
}

countdown( "countdown", 1, 5 );
countdown( "countdown2", 100, 0 );

<div id="countdown"></div>
<div id="countdown2"></div>

div {
    color: #1B232F;
    font-family: Verdana, Arial, sans-serif;
    font-size: 18px;
    font-weight: bold;
    text-decoration: none;
}



List of Articles
번호 제목 날짜 조회 수
179 jquery selector / jquery 선택자 / 자주 사용하는 jquery selector 선택자 / selecter 2016.09.09 8149
178 ajax 아작스 통신 2016.09.09 8046
177 강제 click 이벤트 발생 2016.09.09 7735
176 벨리데이션 체크 / validator / 자동 입력 제한 2016.09.09 7142
175 각종 다이어그램 플러그인 / 차트 / 관계 플러그인 2016.09.09 9489
174 jqGrid / custom pager / custom paging / 그리드 / 페이징 file 2016.09.09 12534
173 [jQuery Plugin] FCKeditor 2.6.5 사용법 2016.09.11 7179
172 jquery 이용한 이미지 변환 2016.09.11 7362
171 jquery function 생성 2016.09.11 6963
170 [jQuery] 이용 아이디 중복체크 실시간 2016.09.11 8876
169 jQuery Quick API file 2016.09.13 6934
168 이미지 클릭시 확대하기 file 2016.09.21 12650
167 Get방식 파라미터 전송 & 탭 메뉴 선택 2016.09.21 8566
166 간단한 세로 메뉴 file 2016.09.21 7306
165 Input TYPE=“File” 을 히든으로 하고 외부 버튼을 눌러서 파일을 선택 2016.09.21 6801
164 document.getElementById() 처럼 DOM 객체 얻기 2016.09.21 6810
163 select box 값 변경, 목록 변경 2016.09.21 9065
162 슬라이드 쇼 file 2016.09.21 6611
161 jQuery Cookie 2016.09.21 6864
160 체크박스 또는 라디오 버튼의 체크여부 변경하기 2016.09.21 6667
Board Pagination Prev 1 2 3 4 5 6 7 8 9 Next
/ 9

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved