<script src="https://code.jquery.com/jquery-latest.js"></script> <video id="hz" loop muted controls> <source src="https://thumbs.gfycat.com/FoolhardyMiserlyAsiantrumpetfish-mobile.mp4" type="video/mp4"> </video> <script> $(document).ready(function() { var bodyOffset = $('body').offset(); $(window).scroll(function() { if ($(document).scrollTop() > bodyOffset.top) { $('#hz').addClass('scroll'); $('.scroll').get(0).play(); } else { $('.scroll').get(0).pause(); $('#hz').removeClass('scroll'); } }); }); </script> 결과보기
<script src="https://code.jquery.com/jquery-latest.js"></script>
<video id="hz" loop muted controls>
<source src="https://thumbs.gfycat.com/FoolhardyMiserlyAsiantrumpetfish-mobile.mp4" type="video/mp4">
</video>
<script>
$(document).ready(function() {
var bodyOffset = $('body').offset();
$(window).scroll(function() {
if ($(document).scrollTop() > bodyOffset.top) {
$('#hz').addClass('scroll');
$('.scroll').get(0).play();
} else {
$('.scroll').get(0).pause();
$('#hz').removeClass('scroll');
}
});
</script>
결과보기