아랄라랄라
R 스토리
아랄라랄라
전체 방문자
오늘
어제
  • All (197)
    • Web (144)
      • Markup | WEB (9)
      • Styles (45)
      • javascript (32)
      • jquery (28)
      • vue (16)
      • react (10)
      • more (4)
    • IT (31)
      • CS (3)
      • git hub (5)
      • UI | UX (18)
      • more (5)
    • ETC (22)
      • 이슈노트 (12)
      • 스터디 (10)
      • 아랄라 ☞☜ (0)
      • JOB🛠 (0)

인기 글

반응형
hELLO · Designed By 정상우.
아랄라랄라

R 스토리

Web/jquery

[제이쿼리] 스크롤 부드럽게 내려가기

2018. 5. 15. 15:00

//부드럽게 올라가기

$(function(){

  $(".event_up").click( function() {

    $("html, body").animate( { scrollTop : 0 }, 350 );

    return false;

  } );

});


// 앵커 부드럽게 내려가기

$('a').click(function(){

  $('html, body').animate({scrollTop: $( $.attr(this, 'href') ).offset().top}, 500);

  return false;

});


// 앵커 부드럽게 내려가기

$('a').on('click', function(event){

   event.preventDefault(); 

   var fixedHeight = $('.nav_wrap').height();   // 상단 고정 메뉴

   $('html,body').animate({scrollTop:$( $(this).attr('href') ).offset().top - fixedHeight}, 600, 'linear');

});


// 앵커 부드럽게 내려가기

$('a').on('click', function(e){

   e.preventDefault(); 

   $('html,body').animate({scrollTop:$( $(this).attr('href') ).offset().top}, 400, 'linear');

});


// iframe 안에서 부드럽게 $(window.parent.document)

  var a01_height = $(window.parent.document).find('header').height();

  var a02_height = $(window.parent.document).find('.gnb_2depth').height();

  var a03_height = $(window.parent.document).find('.event_tit').height() + 60;

  var top_height = a01_height + a02_height + a03_height;

$('html, body', window.parent.document).animate({scrollTop:$( $(this).attr('href') ).offset().top + top_height }, 'slow');

728x90
저작자표시 비영리 (새창열림)

'Web > jquery' 카테고리의 다른 글

[AJAX] ajax에서 jquery찾기  (0) 2018.05.15
[AJAX] ajax기본  (0) 2018.05.15
[제이쿼리] iframe에서 부모 접근 컨트롤  (0) 2018.05.15
[제이쿼리] fading / sliding / this  (0) 2018.05.15
[제이쿼리] 스크롤, 위치 값 구하기  (0) 2018.05.15

티스토리툴바