I have a function in Javascript that generates dynamic <input> elements when a button is clicked. The elements get structures as such:
<input name="array[0]" value="Value" />
<input name="array[1]" value="Value" />
What I need to do is via jQuery, replace the value of each of these elements. This would be pretty simple if the name was something like name="array[]", as I could be able to call:
$("input[name='array[]']").each(function(e) {
$(this).val("New Value");
})
To replace them all, but this functionality doesn't work with these name="array[N]" inputs. I wish I could use that first method, but I need the [N] indices for something later on the backend, and changing that would destroy almost all functionality.
Also, I've made a JSFiddle demonstrating this issue, feel free to debug with it.