setTimeout() - 일정시간후 스크립트 실행
setTimeout("함수명()", 시간[1/1000초]); // 1초 : 1000
ex1) 3초후 버튼 보이기
<input id="btn" name="btn" type="button" value="버튼" />
<script>
var btn = document.getElementById('btn');
btn.style.display = 'none';
function showBtn() {
btn.style.display = 'block';
}
setTimeout( "showBtn()", 3000);
</script>
ex2) 실행시간을 다르게 주기
<div id="1">1</div>
<div id="2">2</div>
<div id="3">3</div>
<div id="4">4</div>
<script>
var s = new Array(5,1,3,2); // 초
var i=0;
setTimeout(f, 0);
function f() {
var div = document.getElementsByTagName('div');
for(j=0; j<div.length; j++) div[j].style.display = 'none';
document.getElementById(i+1).style.display = 'block';
setTimeout(f, s[i]*1000);
i = (i == div.length-1)? 0 : ++i;
}
</script>
5초 -> 1초 -> 3초 -> 2초
게시판 목록
팁게시판
디자인과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 5327 |
GINUSSOFT
|
12년 전 | 5121 | |
| 5326 | 12년 전 | 6198 | ||
| 5325 | 12년 전 | 1896 | ||
| 5324 |
|
12년 전 | 1681 | |
| 5323 |
CTOMAN
|
12년 전 | 1954 | |
| 5322 | 12년 전 | 1743 | ||
| 5321 | 12년 전 | 2417 | ||
| 5320 | 12년 전 | 3649 | ||
| 5319 | 12년 전 | 1585 | ||
| 5318 |
프로프리랜서
|
12년 전 | 1339 | |
| 5317 |
프로프리랜서
|
12년 전 | 972 | |
| 5316 |
프로프리랜서
|
12년 전 | 1227 | |
| 5315 |
프로프리랜서
|
12년 전 | 1144 | |
| 5314 |
프로프리랜서
|
12년 전 | 1354 | |
| 5313 |
프로프리랜서
|
12년 전 | 1939 | |
| 5312 |
프로프리랜서
|
12년 전 | 1501 | |
| 5311 |
프로프리랜서
|
12년 전 | 1342 | |
| 5310 |
프로프리랜서
|
12년 전 | 3882 | |
| 5309 |
프로프리랜서
|
12년 전 | 1509 | |
| 5308 | 12년 전 | 1164 | ||
| 5307 | 12년 전 | 5131 | ||
| 5306 | 12년 전 | 2500 | ||
| 5305 |
오늘도망했다
|
12년 전 | 2231 | |
| 5304 |
senseme
|
12년 전 | 3332 | |
| 5303 | 12년 전 | 3615 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기