메뉴 건너뛰기

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

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

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

일단 fadeIn()과 fadeOut()의 메뉴얼을 보고 싶다면 아래를 참조하길 바란다.
fadeIn : http://api.jquery.com/fadeIn/
fadeOut : http://api.jquery.com/fadeOut/
그럼 이 두가지 기능을 알았으니 간단한 응용을 해보자면.. 아래와 같다.

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
at = 1;
function auto_slide(){
  if( at==1 ){
    $('#ts1').fadeOut(3000); //3초동안
    at=0;
  }else{
    $('#ts1').fadeIn(3000); 
    at=1;
  }
  setTimeout('auto_slide()',3000); //3초마다
}

$(function(){
  auto_slide();
});
</script>
</head>

<body>
<div style="position:absolute;top:0px;background-color:blue;width:400px; height:400px;"></div>
<div id="ts1" style="position:absolute;top:0px;background-color:red;width:400px; height:400px;"></div>
</body>
</html>
 
 
 

그림으로 하고 싶었지만, 마땅한 링크도 없고.. 링크란것은.. 오랜기간 후엔.. 사라지곤 해서.. 그냥 배경 색깔로 파랑과 빨강을 정해서 효과를 줬다.
setTimeout()을 이용해서 간단하게 재귀로 짜 본것이니, 직접 돌려보고 응용해보길 바란다.

참고로 fadeTo()와 fadeToggle() 함수도 있으니 알아두길 바란다.
fadeTo : http://api.jquery.com/fadeTo/
fadeToggle : http://api.jquery.com/fadeToggle/

특히 fadeToggle()을 이용하면 위의 함수를 더 간단히 표현할수 있다.
위의 <script></script> 부분을 아래의 소스로 대체 해보면 된다.

<script type="text/javascript">
function auto_slide2(){
  $('#ts1').fadeToggle(3000, "linear");
  setTimeout('auto_slide2()',3000);
}

$(function(){
  auto_slide2();
});
</script>

  1. jqGrid / custom pager / custom paging / 그리드 / 페이징

  2. No Image 25Mar
    by
    2021/03/25 Views 276 

    javascript, jQuery에서 루프 돌리기 예 (for, forEach, each)

  3. No Image 21Sep
    by
    2016/09/21 Views 6801 

    Input TYPE=“File” 을 히든으로 하고 외부 버튼을 눌러서 파일을 선택

  4. No Image 26Mar
    by
    2021/03/26 Views 176 

    input checkbox 모두 체크하기

  5. No Image 07Nov
    by
    2018/11/07 Views 1403 

    iframe height auto resize

  6. No Image 18Nov
    by
    2016/11/18 Views 7118 

    html 테이블 고정 (table fixed)

  7. Html 색상표 모음, 색상코드표 (RGB), 이미지X, 복사 가능

  8. hover 메소드를 이용해서 메뉴 on, off를 구현

  9. No Image 07Nov
    by
    2018/11/07 Views 1296 

    Hide pager if bxslider has only 1 slide

  10. No Image 21Sep
    by
    2016/09/21 Views 8566 

    Get방식 파라미터 전송 & 탭 메뉴 선택

  11. No Image 21Sep
    by
    2016/09/21 Views 7125 

    getScript()

  12. No Image 21Sep
    by
    2016/09/21 Views 8379 

    getJSON() 함수

  13. No Image 07Nov
    by
    2018/11/07 Views 1299 

    getElementsByClassName 을 IE8 이하에서 동작하게 하는 코드

  14. No Image 21Sep
    by
    2016/09/21 Views 7346 

    FORM 객체 초기화 하기

  15. No Image 26Mar
    by
    2021/03/26 Views 195 

    foreach문

  16. No Image 26Mar
    by
    2021/03/26 Views 171 

    focus() 로 오브젝트 옮기기

  17. No Image 26Mar
    by 조쉬
    2021/03/26 Views 285 

    fadeIn() , fadeOut() 을 이용한 간단한 자동 그림 전환

  18. easing - 효과의 진행 속도

  19. No Image 31Mar
    by
    2021/03/31 Views 273 

    draggable - div 드래그

  20. No Image 21Sep
    by
    2016/09/21 Views 6810 

    document.getElementById() 처럼 DOM 객체 얻기

Board Pagination Prev 1 ... 3 4 5 6 7 8 9 Next
/ 9

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

© k2s0o1d4e0s2i1g5n. All Rights Reserved