Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:01:48+00:00 2026-05-22T15:01:48+00:00

If you know the Index, Value or Text. also if you don’t have an

  • 0

If you know the Index, Value or Text. also if you don’t have an ID for a direct reference.

This, this and this are all helpful answers.

Example markup

<div class="selDiv">
  <select class="opts">
    <option selected value="DEFAULT">Default</option>
    <option value="SEL1">Selection 1</option>
    <option value="SEL2">Selection 2</option>
  </select>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:01:49+00:00Added an answer on May 22, 2026 at 3:01 pm

    A selector to get the middle option-element by value is

    $('.selDiv option[value="SEL1"]')
    

    For an index:

    $('.selDiv option:eq(1)')
    

    For a known text:

    $('.selDiv option:contains("Selection 1")')
    

    EDIT: As commented above the OP might have been after changing the selected item of the dropdown. In version 1.6 and higher the prop() method is recommended:

    $('.selDiv option:eq(1)').prop('selected', true)
    

    In older versions:

    $('.selDiv option:eq(1)').attr('selected', 'selected')
    

    EDIT2: after Ryan’s comment. A match on “Selection 10” might be unwanted. I found no selector to match the full text, but a filter works:

     $('.selDiv option')
        .filter(function(i, e) { return $(e).text() == "Selection 1"})
    

    EDIT3: Use caution with $(e).text() as it can contain a newline making the comparison fail. This happens when the options are implicitly closed (no </option> tag):

    <select ...>
    <option value="1">Selection 1
    <option value="2">Selection 2
       :
    </select>
    

    If you simply use e.text any extra whitespace like the trailing newline will be removed, making the comparison more robust.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml document. I know the index where i need to insert
So let's say I have a matrix, mdat and I only know the index
On clicking child, I want to know the parent index no. Example, there is
I know that a SQL Server full text index can not index more than
I don't know if the title explain this situation well. Below is a code
I have an issue where a ComboBox control will change it's Text value when
this is the demo code: $(document).ready(function(){ $(button).click(function(e) { var value; switch ($(button).index(this)) { case
I want to know column index of header in AdvancedDataGrid when a user clicks
After googling i came to know that Index seek is better than scan. How
I'm trying to find out a way to know the index of a anchor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.