0
I made the following code for when typing in the input field appears the radio Buttons below but it doesn’t work, someone could help me?
$('#amount').onchange('input', function(){
var dinheiro = $(this).val();
if (dinheiro <= 5) {
$("#valArrecadar").show();
$("#valArrecadar2").hide();
$("#valArrecadar3").hide();
$("#valArrecadar4").hide();
$("#valArrecadar5").hide();
} else if (dinheiro <=10) {
$("#valArrecadar").hide();
$("#valArrecadar2").show();
$("#valArrecadar3").hide();
$("#valArrecadar4").hide();
$("#valArrecadar5").hide()
} else if (dinheiro <=25) {
$("#valArrecadar").hide();
$("#valArrecadar2").hide();
$("#valArrecadar3").show();
$("#valArrecadar4").hide();
$("#valArrecadar5").hide()
}else if (dinheiro <=50) {
$("#valArrecadar").hide();
$("#valArrecadar2").hide();
$("#valArrecadar3").hide();
$("#valArrecadar4").show();
$("#valArrecadar5").hide()
}
});
The event
onchange
will only give Trigger when you take the focus of input. Try to usekeyup
in place.– Máttheus Spoo
@Churrozz, you need to improve the title of your question. You are confused
– fernandosavio
It worked, thank you very much!!
– Churrozz
This event
onchange
does not exist in the jQuery this is from Javascript. The jQuery would be$('#amount').on('change', function...)
or else$('#amount').change(function...)
– LeAndrade
@Leandrade I understand, I am new and I end up getting confused when it comes to whether it is javascript or jquery
– Churrozz
Joia man. Another thing I know is just starting but in programming it is always good to tend to create as little code as possible, including repetitions, programming has its basis exactly on this point. Decrease repetitive jobs. In your job you don’t need this lot of Hide(), a way to do this is to give
hide()
in everything that is not the element you want to giveshow()
.– LeAndrade