(→예제) |
(→예제) |
||
27번째 줄: | 27번째 줄: | ||
</script> | </script> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==같이 보기== | ==같이 보기== |
2021년 5월 12일 (수) 17:44 기준 최신판
1 개요[ | ]
- jQuery throttle / debounce
- jQuery 스로틀 / 디바운스
- jquery-throttle-debounce
- 스로틀, 디바운스 기능을 구현한 jQuery 플러그인
2 예제[ | ]
html
Copy
<b>Mousemove Event</b>
<br>Nothing <input type='text' id='output1' disabled>
<br>Throttled <input type='text' id='output2' disabled>
<br>Debounced <input type='text' id='output3' disabled>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js'></script>
<script>
$(window).mousemove( function(e) {
$('#output1').val( e.clientX + ', ' + e.clientY );
})
$(window).mousemove( $.throttle( 500, function(e) {
$('#output2').val( e.clientX + ', ' + e.clientY );
}))
$(window).mousemove( $.debounce( 500, function(e) {
$('#output3').val( e.clientX + ', ' + e.clientY );
}))
</script>
3 같이 보기[ | ]
4 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.