Obtain Values Of Array With Jquery November 20, 2022 Post a Comment Let's say i have this form: Field A Solution 1: Square brackets are used in jQuery selector and we should use escape characters to include the square bracket in id of control; Live Demo iterator = 0; $('#field\\['+iterator +'\\]\\[a\\]').val(); Copy Solution 2: The character "[" is not neutral in jquery selectors : $('#field[0][a]') means : " select the items which have id "field", and also have an attribute named '0', and another attribute named 'a' " You can : either change your way to give an id to your fields, like : id="field_0_a", and thus have $('#field_0_a') work correctly, or select your items by name : $('[name="field[0][a]"]') or do like Adil said Solution 3: Add a class to inputs and do thisBaca JugaDisplay Form Result In Same Page With Only Client-side Script Possible?Js Deleting Submitted Form DataJavascript Interacting With Options jQuery(document).ready(function($){ $('.inputs').each(function(index, object){ console.log($(object).val()); }); }); Copy On your code you need change here: var v = $('#field[iterator][a]').val(); Copy to: var v = $('#field\\['+iterator+'\\]\\[a\\]').val(); Copy Solution 4: The problem is that you have to escape special characters like the following: $('[id="field[' + iterator + '][b]"]').val(); or $('#field\\[' + iterator + '\\]\\[b\\]').val(); demo Share You may like these postsHow To Loop Through An Array With Pure JavascriptPassing An Array From Ejs To JavascriptConvert Json Object Containing Objects Into An Array Of ObjectsCreate Object From Three Arrays Post a Comment for "Obtain Values Of Array With Jquery"