【发布时间】:2021-06-23 17:02:42
【问题描述】:
我想在 wordpress/woocommerce 管理页面中添加一些 jQuery。该代码在客户端页面上运行良好,但从未传递到 wp-admin 页面。
这是代码:
jQuery("#postbox-container-1").ready(function(){
alert("now what?");
$('p:contains("Poivre")').css('color', 'red');
});
【问题讨论】:
-
您需要将脚本加入管理部分。
add_action( 'admin_enqueue_scripts', 'your_enqueue_function' ); -
我使用了下面的代码,但它不起作用...
add_action( 'admin_enqueue_scripts', jQuery("#postbox-container-1").ready(function(){ $('p:contains("Poivre")').css('color', 'red'); }));仍然没有得到它... -
这不是排队脚本的工作方式。您需要传入一个php函数。阅读重复的链接。