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

178
Views
jquery getting options text from different select ids in a function

In the code below if options from both color_select and size_select are selected, only the latest selected option is logged only(e.g either red or small is logged if both are selected depending whichever is selected later). How to log options from both the select(color_select and size_select) on change in one function when option from either of the select is changed (i.e log both red and small if both are selected)?

<h6>Choose Color</h6>
<select id="color_select" name="color" class="form-control" required="">
    <option value="" disabled="" selected="">Select</option>
    <option value="red">Red</option>
    <option value="blue">Blue</option>
    <option value="white">White</option>
</select>

<h6>Choose Size</h6>
<select id="size_select" name="size" class="form-control" required="">
    <option value="" disabled="" selected="">Select</option>
    <option value="small">Small</option>
    <option value="large">Large</option>
    <option value="medium">Medium</option>
</select>

   $('#color_select','#size_select').on('change' , function() {
    // Code here
    var $this = $(this);
   if($this.find('option:selected').index() !== 0){

       text = $this.find('option:selected').text();
       console.log(text);
   }     
}).change()
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!