Hello,
I'm trying find a bunch of <label>s
in a form of mine based on an array of elements and their id attribute.
eg. [ input#country , input#other-country ]
would be able to find <label for="country"> , <label for="other-country">
and so on…
so far I have this code:
var LOCATION = {};
LOCATION.option = form.find('input[name=location]').toArray();
LOCATION.labels = [
$.each( LOCATION.option, function(i, input) {
$('label[for='+input.id+']');
})
];
When logging out the input.id
inside the $.each
loop I get the correct value being written out however I can't seem to find a way to write my matched label
element from inside the $.each
loop into the LOCATION.labels
array afterwards.
Does anyone know how to put them into the array? toArray()
does not seem to work either…
Thanks for reading.