0
I need to get the data of an input with javascript. In this way, I created an up-to-date function.
function atualizaAdicionados(e){
console.log(e.value);
console.log(e.data('id'));
}
<input type="text" class="valor" name="valor_2" value="125.00" data-id="2" id="valor_2" onkeyup="atualizaAdicionados(this)">
Could someone help me or make another suggestion?
OBS.: I believe that I will not be able to work with the input ID field, because they will have several inputs that I will insert in the database (as if they were products of a sale), so each id will be value_ID. What I need is to get the ID only.
e.dataset.id
is also an option.– user201467
yes @v.Santos is an option. I like the
getAttribute
because it serves any attribute other than "date-*", it would be possible to be for example "id-alternative", which would not be possible withdataset
– Ricardo Pontual
You helped me, thank you very much!
– Julio Cesar