I'm pretty new at Javascript and I'm following some code from Code Pen to try and create a shadow effect underneath the nav bar when the page is scrolled. The code looks like this:
$(window).scroll(function() {
if ($(window).scrollTop() > 10) {
$('#navBar').addClass('floatingNav');
} else {
$('#navBar').removeClass('floatingNav');
}
});
When I run this though, the console returns this error (in reference to the first line):
Uncaught ReferenceError: $ is not defined
I'm not sure how to resolve this. I've seen plenty of examples in other people's code where $(window).scroll works fine. Is there a way to define it? Am I missing something?