1
I have an element:
<input id="quantity" name="quantity" min="1" max="3" type="number">
where I store its value in a variable:
var qty = $('#quantity').val();
by default the value is 1.
I wish that every time I changed the amount of that input
he updated the variable in real time qty
because I will pass it as a parameter in another function in a URL, exmeplo:
$('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 by doing this the new value of the variable qty
is not updated in real time in the attribute href
of my button.
Show hadn’t thought of it, I’ll test it the way you quoted it.
'change keyup paste click'
I used after several unsuccessful attempts haha even saw on a stack issue in English.– Steve Angello
didn’t work :( I need it to be updated in real time in the gift case in the href of the button too, because I’m using a bag platform?
– Steve Angello
I don’t know how you did it. I can’t say anything. in practice it should work. I put a complete example...
– Daniel Omine