How to loop through form elements created with the append function
Hello,
How to loop through form elements created with the append function ?
- var html = '<tr>'
- +'<td><input type="text" name="label[]" class="label width400" value="" required /></td>'
- +'<td class="formElem"></td>'
- +'<td><input type="text" name="name_column[]" class="name_column" value="" class="width400" required /></td>'
- +'<td><button type="button" class="removeColumn">-</button></td></tr>';
- var numColumn = $('#numColumn').val();
- for (i = 0; i < numColumn; i++) {
- console.log('i : ' + i);
- $('#table_create').append(html);
- $('#table_create').trigger('create');
- }
On click
button to validate the form, I would like to check if all form inputs exists / are not empty.
I tried :
- $('.label ').each(function(){
- if ( !$(this).val() ){
- alert( "please enter the label");
- }
- });
But only the first row is controlled. There is no iteration through the
other inputs from the same class.
Thank you for your help !
Jocelyne