How can I call the on click function even if the user does not click on the first button in a list of dynamically created buttons?

How can I call the on click function even if the user does not click on the first button in a list of dynamically created buttons?

Hi, I have a number of submit buttons in a loop that are made dynamically.  I’m using jquery like this:

 

 $(document).on('click', '.submit', function () {

 

  mydropdown = $('#Category');

 

               if (mydropdown.length == 0 || $(mydropdown).val() == "") {

                   alert("Please select an 'a category'.");

 

                   return false;

 

               

               }

});

 

but the alert does not fire and the page still gets submitted it I click a button other than the 1st one.  Is there a way to call the click function even if the user does not click on the first button in the list?