How to override Plugin javascript function : $('body').on('change','.class')

EDITED: Extensively rewritten after some research

Requirement

I need to override a script in the custom.js of a 3rd party plugin.

$('body').on('change', '.wpt_row input.input-text.qty.text', function() {
   (some javascript code here)
}`

What I know so far

I need to:

  • dequeue the plugin script in
    • /wp-content/plugins/3rd-party-plugin/assets/custom.js
  • and then enqueue my own script from
    • /wp-content/themes/my-child-theme/includes/js/my_child_scripts.js

To achieve this I must add something like this to my child theme functions.php:

add_action('wp_enqueue_scripts', 'my_mod_script_load', 100);
function my_mod_script_load()
{
    wp_dequeue_script('THE_PLUGIN_SCRIPT');
    wp_enqueue_script('MY_MOD_SCRIPT', get_stylesheet_directory_uri().'/js/scripts.js');
}

Where I get stuck

The script I want to override is an 'event based function', and not a 'named function'.

I am nor sure how to reference that in the dequeue and enqueue calls.

In the above, what would I use for:

THE_PLUGIN_SCRIPT

MY_MOD_SCRIPT


Thanks to @WebElaine for giving me a nudge in the right direction.

Topic body-class plugins Wordpress javascript

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.