Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个简单的 jQuery 脚本来管理表单。我已经使用脚本在标题中插入了代码$(window).load(function(){... 但是如果调用该函数,该脚本将不起作用<?php wp_footer(); ?>。如果我尝试删除它,我的脚本可以工作。有什么建议吗?谢谢
$(window).load(function(){...
<?php wp_footer(); ?>
不要在 Wordpress 中使用!$(window).load(function(){...
您需要一个无冲突的 DOM 就绪包装器,因为 Wordpress 默认处于无冲突模式:
jQuery(function($) { // your code goes here $('#myElementID').css('color', 'red'); // example });
并确保脚本包含在 jQuery 文件之后,您通常会通过在wp_enque_script()
wp_enque_script()