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

406
Views
jQuery - How to select dropdown list item by text?

How would I select my dropdown list item by text rather than value?

I want to select a dropdown item by text with jQuery.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

use :contains()(link)

$("select option:contains(text)").attr('selected', true);

demo

over 4 years ago · Santiago Trujillo Report

0

There is a filter function on jQuery that you can use to get elements with something more specific

$("select option").filter(function() {
    return $(this).text() == "text_to_select";
});

This is going to return all options with the "text_to_select" in the text.

over 4 years ago · Santiago Trujillo Report

0

i think this will do the trick for you...

$("#selectId").find("option:contains('text')").each(function(){
  if( $(this).text() == 'Text that should be matched' ) {
    $(this).attr("selected","selected");
  }
});
over 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!