Newbie question. Given the following html.
<div id="mycontainer1" class="container">
<input type="text" class="name"/>
<input type="text" class="age"/>
</div>
<div id="mycontainer2" class="container">
<input type="text" class="name"/>
<input type="text" class="age"/>
</div>
I'm trying to create a function where I can pass an element id and an array that contains the classes of the input values I want to get.
So for example,
var inputClasses = ['name','age'];
getInputValue('.container', inputClasses);
function getInputValue(elem, arr) {
$(elem).each(function() {
// need a way to map items in array to variables
// but how do I do this dynamically?
var nameValue = $(this).find('.name').val();
var ageValue = $(this).find('.age').val();
});