I must have something set up incorrectly in my custom theme. jQuery is loading and works fine elsewhere on the same page in a views slideshow using jquery.cycle. My custom JavaScript however reports that $
is not a function.
The info.yml file includes the global-scripts property.
The libraries.yml file contains the following code.
js:
js/script.js: {}
dependencies:
- core/jquery
The content of js/script.js is the following.
$(document).ready(function () {
$(window).on('load scroll', function () {
var scrolled = $(this).scrollTop();
$('#layer-1').css('transform', 'translate3d(0, ' + -(scrolled * 0.25) + 'px, 0)'); // parallax (25% scroll rate)
});
});
The first line in script.js returns the error in the console. It is the only error I receive.
I checked the page source and confirmed that jQuery is being loaded before script.js at the bottom of the page below the footer.
Can anyone see what I have done wrong here?