[JavaScript] 스크롤 고정 및 해제 방법
2021. 2. 17. 21:13ㆍHTML&CSS&JavaScript
<스크롤 고정>
해당 element 위에서 터치를 하거나(touchmove) 마우스 휠을 통해 스크롤을 하려는 경우(mousewheel) 이를 차단해서 스크롤을 방지해주는 쿼리
$('#element').on('scroll touchmove mousewheel', function(event) {
event.preventDefault();
event.stopPropagation();
return false;
});
<스크롤 고정 해제>
해당 element에 적용되고 있던 스크롤 락을 해제하는 쿼리
$('#element').off('scroll touchmove mousewheel');
'HTML&CSS&JavaScript' 카테고리의 다른 글
bootstrap, tailwind (0) | 2021.03.10 |
---|---|
[JavaScript] JS의 변수를 JSP로 넘기기??? (0) | 2021.03.09 |
[HTML&CSS] 텍스트 줄넘침 해결 방법(2가지) (0) | 2021.02.17 |
[JavaScript] top button, bottom button (0) | 2021.02.15 |
[javaScript] URL의 파라미터를 찾는 함수 (0) | 2021.02.12 |