I want a html5 video being muted when the user scrolls to a div container (#scroll). Therefore I tried to use this code:
$(document).ready(function(){
$(window).scroll(function(){
// Der Referenzwert der minimal Höhe
var height = $('#scroll').offset();
// Die aktuelle Fensterposition (nach dem Scrollen)
var current = $(window).scrollTop();
// Umgekehrte Logik
if( current < height.top ){
$('video').setAttribute('muted');
} else {
$('video').removeAttribute('muted');
}
});
});
It's not working for me but I can't find the bug. Please help me. Thank you!