1
I have a code that dynamically registers input data in the localStorage.
I am trying to recover the data registered in their respective inputs, but without success.
This is the code to recover the data, but only recovers the first data registered:
$("#exibir").click(function(){
for (var i = 0; i < localStorage.length; i++){
var inputs = $('input[type="text"]');
inputs.val(localStorage.getItem(localStorage.key(i)));
}
})
Thanks in advance!
I modified it yesterday and ended up getting:
$("#exibir").on('click', function() {
 $('input[type="text"]').each(function() {
 var id = $(this).attr('id');
 var value = $(this).val();
 var inputs = $('input[id="' + id + '"]');
 inputs.val(localStorage.getItem(id));
 });
})
– Guilherme Lirio
Ah yes, with
.each()
. That’s it! D– Matheus Avellar