Obtain Values Of Array With Jquery December 27, 2023 Post a Comment Let's say i have this form: Field ASolution 1: Square brackets are used in jQuery selector and we should use escape characters to include the square bracket in id of control;Live Demoiterator = 0; $('#field\\['+iterator +'\\]\\[a\\]').val(); CopySolution 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 saidSolution 3: Add a class to inputs and do thisjQuery(document).ready(function($){ $('.inputs').each(function(index, object){ console.log($(object).val()); }); }); CopyOn your code you need change here:var v = $('#field[iterator][a]').val(); Copyto:var v = $('#field\\['+iterator+'\\]\\[a\\]').val(); CopySolution 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 Post a Comment for "Obtain Values Of Array With Jquery"