Image slider plugin: simulating a click on window load does not work after updating the jQuery library

Image slider plugin: simulating a click on window load does not work after updating the jQuery library

I am building an image slider plugin with Next and Previous buttons and an auto advance feature.

The auto advance happens by triggering clicks on the Next button at equal intervals:

  1. $(window).on('load', function() {
  2.          autoAdvanceInterval = setInterval(function() {
  3.             $('#next').trigger('click');
  4.          }, settings.pause);
  5.          // When a control or dot is clicked by user
  6.          // stop autoadvance by clearInterval method 
  7.          $('.controls a,.bullets li').click(function(event) {
  8.             if (event.originalEvent !== undefined) {
  9.               clearInterval(autoAdvanceInterval);
  10.            }
  11.          });
  12.   });

The auto advance stooped working after updating jQuery from v2.0.0 to v3.2.1. I replaced $(window).load() with (window).on('load', ... but it still does not work.

What am I doing wrong? Thank you!