Jquery instructions for traversing the checkbox

  • 2020-03-30 02:04:13
  • OfStack

When working on the front-end project these two days, I want to iterate over the checkbox on the page through jquery with the following code:


var val_instanceCodeStr = "";
$("input[type='checkbox']  [name='chk_jvmMachineName']:checked").each(
        function() {
         val_instanceCodeStr += ","+$(this).val();   
        }
     );

The val_instanceCodeStr variable is still an empty string, and the function function is not executed.

I found that there was an extra space between [type='checkbox'] [name='chk_jvmMachineName']

Jquery multiple selectors cannot be separated by Spaces


Related articles: