I’m writing right here as a result of i’ve WordPress 6.0, i’m attempting to incorporate JQuery in my theme beacuse i’ve to start out engaged on a performance i would like. The issue is that JQuery shouldn’t be loading accurately i suppose as a result of in my chrome developer console i received this error:
Jquery shouldn’t be acknowledged however i do not undersand why, as a result of i’ve all the time adopted WordPress practices and as you may see beneath within the code apparently there’s nothing unsuitable. WordPress has already its personal Jquery, i do not need an exterior Jquery library even in CDN, i do not skinny is required one other JQuery.
Right here is the code for enqueuing extra js scripts in features.php:
operate load_custom_jquery_edit(){
wp_enqueue_script('jquery');
wp_enqueue_script('customize-jq',
get_template_directory_uri().'/belongings/js/customize-jq.js',
array('jquery'),
"1.1.0",
true);
}
add_action('wp_enqueue_scripts', 'load_custom_jquery_edit');
That is my JQuery extra file:
(operate($){
$(doc).prepared(operate(){
//testing instance
$('test-my-new-submit-btn')
.attr('id','testBtn');
$('#testBtn').on('click on', operate(e){
e.preventDefault();
let success_msg = "success!!!";
alert(success_msg);
//Different issues to do subsequent
});
});
})(JQuery);