Bind JS event to WordPress control customizer

I want to bind a click event to WordPress custom control (Theme Customizer). I have tried with (customizer.js):

$(document).on(‘click’, ‘.element_class’, function () {
console.log(5);
});

, but it doesn’t bind.

The control is something like :

<div class=”element_class”>
Value
</div>

functions.php:

function customizer_live_preview() {
wp_enqueue_script(
‘theme-customizer’,
get_stylesheet_directory_uri() . ‘customizer.js’,
array( ‘customize-preview’ ), ‘0.1.0’, true);
}
add_action( ‘customize_preview_init’, ‘customizer_live_preview’ );

Read more here:: Bind JS event to WordPress control customizer

Leave a Reply

Your email address will not be published. Required fields are marked *