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 =  $(&quot;input.countme:checked&quot;).length // count all checked checkboxes with the css class &quot;countme&quot;
        $(&quot;.cm_score&quot;).val(a)  //update the value of the textfield that has the class &quot;.cm_score&quot; 
    }); 
})(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
Following the tips in this post, I changed the code as follows and it worked:
(function ($, Drupal) {
 Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
    $('input.countme').change(function(){   
        var a =  $(&quot;input.countme:checked&quot;).length // count all checked checkboxes with the css class &quot;countme&quot;
        $(&quot;.cm_score&quot;).val(a)  //update the value of the textfield that has the class &quot;.cm_score&quot; 
    }); 
 }
};
})(jQuery, Drupal);