4
How to identify if a determining value has been changed in input
? I have the prototype below, however alert
will be displayed according to the number of times the class="ultimo-valor"
appears in the code.
<input class="ultimo-valor" onKeyUp="ultimoValor(this)" type="text"
value="<?php echo $ultimo_valor; ?>"/>
<input class="ultimo-valor" onKeyUp="ultimoValor(this)" type="text"
value="<?php echo $ultimo_valor; ?>"/>
Script:
<script>
$(document).ready(
function ultimoValor(e) {
$('.ultimo-valor').on("change paste keyup", function() {
alert($(this).val());
});
});
</script>
Are you making a mistake? It’s not working?
– LocalHost
http://jsfiddle.net/teuwLswp/
– lucasbento
@Localhost, the
alert
should be displayed only once for each change.– lucasbento
published an answer, see if that’s it
– LocalHost
@Localhost, thanks for the help. I don’t know if I explained the problem clearly, but Marcelobonifazio answered correctly.
– lucasbento
I believe that the answers were not so different. But I’m glad you got the expected result :)
– LocalHost
Can you change it to more than one
input
?– lucasbento
Yes... edited there, I had withdrawn just to get better visualizing...
– LocalHost