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

212
Views
$('select').change(function but on only one specific dropdown? (HTML, Javascript)

I'm trying to do that this code:

$(document).ready(function () {
$('select').change(function () {
    alert(this.value);
});

Alerts a message but only when one of the various dropdowns onscreen is selected. But it works whenever I pick ANY dropdown. How can I do it so that it only works with one specific dropdown?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Simply give your respective select tag an id, then use that id for your selector in your jQuery:

$('#select1').change(function () 
{
    alert(this.value);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<select id="select1">
  <option value="">--Please Choose--</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
</select>

<select id="select2">
  <option value="">--Please Choose--</option>
  <option value="A">Apple</option>
  <option value="B">Banana</option>
  <option value="C">Cherry</option>
</select>

about 4 years ago · Santiago Trujillo Report
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!