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

  • SEARCH
  • Home
  • 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 9136233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:55:33+00:00 2026-06-17T08:55:33+00:00

<select id=mySelect> <option id=sel01 value=some value>some value</option> <option id=sel02 value=some other value>some other value</option>

  • 0
<select id="mySelect">
  <option id="sel01" value="some value">some value</option>
  <option id="sel02" value="some other value">some other value</option>
  <option id="sel03" value="maybe me">maybe me</option>
  <option id="sel04" value="and another one">and another one</option>
</select>

I would like to select an option with use of jQuery, but not by value:

$("#mySelect").val(1);

but by elements id.

Thanks for an answer.

  • 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-06-17T08:55:34+00:00Added an answer on June 17, 2026 at 8:55 am

    You can use prop method.

    var id = 'sel02';
    
    $('#mySelect option').filter(function(){
       return this.id === id
    }).prop('selected', true);
    

    or:

    $('#' + id).prop('selected', true);
    

    Or if you want to select an option based on it’s index, you can use eq method:

    $('#mySelect option').eq(1).prop('selected', true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some html element like these: <table id=myTable></table> <select name=mySelect> <option value=1>1</option> <option
Normally I would do something like this: <select name=myselect> <option value=opt1 <?=($_POST['myselect']==opt1?SELECTED:)?>>Option 1</option> <option
Given a select <select id=Myselect> <option value=-1>Please Select<option> <option value=1>Selection 1<option> <option value=2>Selection 2<option>
Example: <select id=myselect> <option value=A>First</option> <option value=B>Second</option> <option value=C selected=selected>Third</option> <option value=D>Fourth</option> </select> Using
Say I have: HTML: <select id=mySelect><option value=0>option-1</option>...</select> JS: var select = $(#mySelect); and I
The following code works perfectly in non-IE browsers. <select id=mySelect name=mySelect> <option value=1>MyVal1</option> <option
iam having the select box <select id =myselect> <option value=AA>AA</option> <option value=AB>AB</option> <option value=AC>AC</option>
I have <div id=myselect> <select> <option value=0>1</option> <option value=1>2</option> </select> </div> Im trying to
I have a form: <form id=myForm> <select name=mySelect> <option value=250>250</option> <option value=500>500</option> </select> <input
This is not working on Chrome? <select id=mySelect onmouseout=defocusSelect()> <option>A</option> <option>B</option> </select> ... function

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.