I have a <input id="quantity" name="quantity" min="1" max="3" type="number">
element where I store its value in a var qty = $('#quantity').val();
variable by default the value is 1.
I would like that whenever I change the amount of this input
it updates in real time the variable qty
since I will pass it as a parameter in another function in a URL eg: $('meu-botao').attr('href','/busca/quantidade='+qty)
.
I used the function:
var qty = 0;
$('#quantity').on('change keyup paste click',function() {
qty = $(this).val();
});
But doing so the new value of the variable qty
is not updated in real time in the href
attribute of my button.
Thanks to all who can help, thank you.