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 8504873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:09:29+00:00 2026-06-11T02:09:29+00:00

Consider the following situation, I have a select element <select> <option>a</option> <option selected=selected>b</option> <option

  • 0

Consider the following situation,

I have a select element

<select>
    <option>a</option>
    <option selected="selected">b</option>
    <option selected="selected">c</option>
</select>

Then using jquery I set the multiple attribute

$( 'select' ).attr( 'multiple', true );

Why does the following code returns false?

$( 'select' ).children( 'option' ).eq( 1 ).is( ':selected' )

While this returns true,

$( 'select' ).children( 'option' ).eq( 2 ).is( ':selected' )

But if the select element’s multiple attribute was set manually on the HTML code, both of them returns true. (tried on webkit, firefox and IE)

Is it a mistake on my side, or is this the expected behavior?

Thank you

  • 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-11T02:09:31+00:00Added an answer on June 11, 2026 at 2:09 am

    Because the select is rendered without multiple attribute set, only the last selected option is actually selected. You would need to set the selected options after you allow multiple values.

    Both your queries return what you expect. The thing you miss is that your b option is actually not selected. Check what is rendered in browser.

    EDIT: This line fixes the behaviour, add it after your multiple selection activation:

    $('select').html($('select').html());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following situation. I have 3 tables in a resource planning project(created using
Consider the following situation: We have two Localizable.string files, one in en.lproj and one
Consider the following situation: I have two android projects named P1 and P2 which
Consider the following common situation: You have some MainView in your Cocoa application, loaded
consider the following situation: I have a string s and hash function H generating
consider the following situation: In order to have lots of work processed at my
So, please consider the following situation I have a super class of type Shapes
Consider I have the following situation: I have a branch br_foo from revision 4.
Consider the following situation where I have a list of n matrices (this is
Consider the following situation: I have a library that includes a third party library.

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.