I’m building a WordPress site that has the following bit of JS:
jQuery(window).load(function($) {
console.log('Everything loaded');
$('.slides').fadeIn();
});
I’m seeing “Everything loaded” in the console, but the following line causes an error:
Uncaught TypeError: n is not a function
I don’t understand what’s causing the problem. The JS file has jQuery as a dependency, and there are other jQuery functions that are working fine. It’s just the above section that’s causing an error.
Here’s a screenshot from the console, because some people are having difficulty believing the above code is causing the error.
The issue is because you have set the event parameter as provided to the handler function with the name of
$
. This overwrites the jQuery instance of$
, hence the error. You just need to remove the$
from the function parameters:Note that from your comments you’re looking to alias the
jQuery
variable as a$
after usingnoConflict()
. To do this you can use this signaturedocument.ready
handler://try below code (remove $ )