The script does not work, and the ebugging screen shows the error
$ is not defined
<script href="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(window).on('scroll', function(){
if($(window).scrollTop()){
$('nav').addClass('black');
}else{
$('nav').removeClass('black');
}
})