As you typed in the input field appeared the radios button below

Asked

Viewed 16 times

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 use keyup in place.

  • @Churrozz, you need to improve the title of your question. You are confused

  • It worked, thank you very much!!

  • 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 I understand, I am new and I end up getting confused when it comes to whether it is javascript or jquery

  • 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 give show().

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.