jQuery works in console but not when in a file
Question
I don’t know wp_enqueue_script
works. I tested and works fine. but you can use the wp_footer
hook and you can add your custom js. check below code. code will go to the active theme functions.php file.
function add_custom_scripts(){ ?>
<script type="text/javascript">
(function($){
$(document).ready(function() {
$( '#menu-item-927' ).on( 'ubermenuopen', function(){
$('.site-content').addClass('blur');
});
});
})(jQuery);
</script>
<?php }
add_action( 'wp_footer', 'add_custom_scripts', 10, 1 );
0
2 years
2021-03-24T20:33:02-05:00
2021-03-24T20:33:02-05:00 0 Answers
0 views
0
Leave an answer