我在wordpress中排队js文件并加载文件并使用本机js代码但jQuery准备好无法正常工作
alert('working');
jQuery(document).ready(function(){
alert('not working');
});
网站网址 http://typingbooster.expotech.co.in/ 请查看源文件custom.js
在wordPress环境中,使用:
jQuery(document).ready(function($){ });
你确定jQuery已经入队吗?您可以通过将其添加到您的functions.php来确保它:
add_action('init', 'load_jquery_scripts', 0);
function load_jquery_scripts() {
wp_enqueue_script('jquery');
}
window.addEventListener("load", function(){
alert('works');
});
希望这对你有用!