Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
The Select case feature in Jquery does not work

I am creating a game that is supposed to help me and learn somethings, but I have run into a problem which I can figure out. The problem is that I have created a select tag and they need to select the speed they want, but when they click it, the selection does not work. It returns 50 once then it returns 500 I don't not know why, I have aa excerpt of my game below and under that is the full code, Please check them both out thank you.

Excerpt from the Game:

$(document).ready(function() {

  let NewSpeed = $("#Selection option:selected").val();
  // console.log(NewSpeed)
  $("input").click(function() {
    let TimeSpeed;
    console.log("This Part Excuts")

    switch (NewSpeed) {
      case (NewSpeed = 100):
        TimeSpeed = 100;
        break;
      case (NewSpeed = 300):
        TimeSpeed = 300;
        break;
      case (NewSpeed = 500):
        TimeSpeed = 500;
        break;
      default:
        TimeSpeed = 50;
        break;
    }

    console.log(TimeSpeed)
  })

})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>

<head>
</head>

<body>
  <form action="#">
    <select id="Selection">
      <option value="50">50</option>
      <option value="100">100</option>
      <option value="300">300</option>
      <option value="500">500</option>
    </select>
  </form>

  <input type="button" name="btn" id="btn" value="Click Me" />

</body>

</html>

Full Version: https://codepen.io/Giannilmgc/pen/JjrgZdr

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda