Objectives:
- Create Two dimension array in javascript/jquery
- Push data into it
- Loop through each key,value pair
- Call function in loop
Code:
var IDs = [];
/* Find Input elements and push its ID & Value into an array */
$('#divDynamicFields').find("input").each(function () {
IDs.push(this.id, $(this).val());
});
console.log(IDs); /* Now it prints string seprated by ',' */
/* Loop Through Each element in 2D array */
$.each(IDs, function(key, value) {
$.each(key, function(innerKey, innerValue){
CallFunction(id,val);
/* Will This Work ? */
}
}
id,valueas pair