您需要将一个单独的脚本排队到具有不同依赖关系的不同操作上。
/**
* Enqueue styles and scripts for the Customizer pane.
*/
function mytheme_customize_pane_enqueue() {
wp_enqueue_script( \'mytheme-customizer-control\',
get_template_directory_uri() . \'/js/customizer-control.js\',
array( \'customize-controls\' ), \'20180924\', true );
}
add_action( \'customize_controls_enqueue_scripts\', \'mytheme_customize_pane_enqueue\' );
JS如下所示:
( function( wp, $ ) {
wp.customize.control( \'mytheme_option\', function( control ) {
control.container.on( \'click\', \'.element_class\', function( event ) {
event.stopPropagation();
//control.doNotice( \'\' );
//control.applyPresetValues( $( this ).data( \'revert\' ) );
} );
} );
} )( wp, jQuery );