Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!