我想你必须用jQuery来解决这个问题。如果checked
-> addClass
, 如果没有->removeClass
.
以下是如何将JS文件排队:
add_action(\'admin_menu\', \'fwds_plugin_settings\');
function fwds_plugin_settings() {
$hook = add_menu_page(
\'Price Display\',
\'Price Display\',
\'add_users\',
\'fwds_settings\',
\'fwds_display_settings\'
);
add_action( "admin_print_scripts-$hook", \'fwds_print_scripts\' );
}
function fwds_print_scripts()
{
wp_register_script(
\'my-fx\'
, plugin_dir_url( __FILE__ ) . \'/my-fx.js\'
, array( \'jquery\' ) // Dependencies
);
wp_enqueue_script( \'my-fx\' );
}
以及
my-fx.js
:
jQuery(document).ready(function($)
{
alert(\'my page\');
});