How to use jQuery in WordPress 5.7+

Question

If jQuery is included in WordPress, why do I get ‘jQuery is undefined’ errors?
I cannot find a tutorial (one would think this would be in the WordPress docs) on how to use jQuery in modern versions of WordPress (I’m using 5.7). Do I need to enqueue anything? Deregister anything? Do anything in functions.php. I’ve tried:

var $j = jQuery.noConflict();
jQuery(document).ready(function($)
(function($) {

Is there documentation anywhere that explains the basic methods of using jQuery in my WordPress code? Everything I can find on the Interwebs is old or doesn’t solve the issue.

Thanks.

0
breadwild 4 months 2021-07-07T23:09:00-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse