i want to change CSS or menu bar while scrolling and restore old CSS when scroll stops using if else. this is what i did so far.
if ($(window).scroll(function () {
$('#nav').css('opacity', '0.85');
} else {
$('#nav').css('opacity', '1');
});
working code without if statement
$(document).scroll(function() {
$('#nav').css('opacity', '0.85');
});