html - Getting non-existing ids of textarea on each function of javascript? -
i have created user form dynamically in input , textarea controls getting created dynamically. here in below code, trying fetch ids of input , textarea of particular form , in case of input, getting right values getting wrong values textarea.
$('#detailcontact input, textarea').each(function() { arr[i++] = this.id; }); only 1 textarea on form, function returns multiple non-existing ids of textarea.
you need do:
$('#detailcontact input, #detailcontact textarea').each(function() { arr[i++] = this.id; }); or use .find instead.
$('#detailcontact').find('input,textarea').each(function() { arr[i++] = this.id; }); you with:
$('input,textarea', '#detailcontact').each(function() { arr[i++] = this.id; });