I have a a handful of dynamically generated inputs. Some have IDs, some do not.I also have an array of IDs. I need to loop through the array of IDs and input the next available ID into the next input without a value.
I have tried
$.each(event_array, function(intIndex, objValue){
$('.event-data').find('.event-id').each(function(i){
$(".event-id:empty").val(objValue);
});
});
And
$('.event-data').find('.event-id').each(function(i){
$(".event-id").val(event_array[i]);
});
Obviously the second one doesn’t search for the value of the input and the first one uses :empty which I have found out is not for what I am using it for.
Any idea what I need to use for this to work?
Thanks!!
This will filter through the
.event-idelements for the ones that don’t have a value, then passes a function to.val()that returns the array element matching the current index.Passing a function to
.val()requires jQuery 1.4 or later.