javascript – why my custom jquery code stopped working on a multipage webform after upgrade to WF x6


I have a long questionnaire as multi-page webform and I do many mostly simple counting and addclass using jquery done via a custom module I made for the purpose. This was perfectly working before on Drupal 8 with WF x5 but not anymore after upgrading to Webform x6 (dev) on latest Drupal 9.02.

The below sample code only works if I move the related form to be on first page while it doesn’t load on later pages!

(function($, load) {
    $('input.countme').change(function(){   
        var a =  $("input.countme:checked").length // count all checked checkboxes with the css class "countme"
        $(".cm_score").val(a)  //update the value of the textfield that has the class ".cm_score" 
    }); 
})(jQuery);

Below is myModule.libraries.yml

wfcount:
  version: VERSION
  css:
    theme:
      css/webform.css: { preprocess: false }
  js: 
    js/wfCount.js: { preprocess: false }    
  dependencies:
    - core/jquery