스크롤 막는 스크립트


1
2
3
4
5
$('선택자').on('scroll touchmove mousewheel'function(event) {
  event.preventDefault();
  event.stopPropagation();
  return false;
});
cs



해제 


1
$('선택자').off('scroll touchmove mousewheel');
cs




위의 방법은 스크롤 이벤트를 꺼버린다. 

다른 스크롤을 이용하는 다른 이벤트가 있다면 아래의 다른 방법을 사용



다른 방법


1
2
3
4
5
6
// 스크롤 막기
$('html, body').css({'overflow''hidden''height''100%'});
 
 
// 해제
$('html, body').css({'overflow''auto''height''auto'});
cs


'퍼블리싱 > JS & JQ' 카테고리의 다른 글

.is(':animated') 활용 중복동작 방지  (0) 2019.01.15
트윈맥스 애니메이션 중 실행 막기  (0) 2018.11.19
JS에서 미디어쿼리를 사용하는 matchMedia()  (0) 2018.11.01
JQuery API  (0) 2018.11.01
컬러박스 사용법  (0) 2018.11.01

+ Recent posts