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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:24:48+00:00 2026-06-04T02:24:48+00:00

I have tried to bind those two code ideas together but it isn’t working.

  • 0

I have tried to bind those two code ideas together but it isn’t working.

I want to disable the first option from being selectable after a selection has been made.

This is the behavior I’m wanting; the first option is disabled after a selection is made.

And this is my code where I want the first option disabled when a subsequent element is picked.

  • 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-04T02:24:49+00:00Added an answer on June 4, 2026 at 2:24 am

    I believe this answers your inquiry:

    http://jsfiddle.net/dq97z/66/

    Inside of displayVals I executed the following:

    if ($("#menucompare").prop("selectedIndex") !== "0") {
        // Within the select (you could be more specific) find
        // the first (direct descendant) option value and 
        // disable it to make it unselectable
        $("select > option:first").prop("disabled", "disabled")
    }
    

    This segment finds out what the selected index of your select menu is and if the user has selected something other than the initial one (0), it sets the first option to be disabled.

    Update: http://jsfiddle.net/dq97z/72/

    Changed attr() to prop() when disabling per the documentation and @silkster’s advice. Thanks

    Also, if you don’t want the option selectable at the beginning, you could even do it without an if statement as seen here.

    function displayVals() {
        var singleValues = $("select option:selected").text();
        ....
        $("select > option:first").prop("disabled", "disabled")
    }
    

    The disabling happens after the DOM is loaded (with the first one not disabled) so the select can still have ‘Please select’ selected. Whoah…that’s a lot of “select”s.

    If you want to leave the if statement there (which means ‘select one’ is selectable until another is actually selected), your if statement would need to be like this:

    if ($("#menucompare").prop("selectedIndex") !== 0) // with no quotes around zero
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I've Tried jQuery's $.getScript does two of those things, but I don't know
I have tried several things so far, but I haven't had much luck yet.
I have tried this but it does not work (even if I specify .wav
I have tried quite a few codes but none of them seem to work
I have tried to find some decent documentation on traversing in jQuery, but have
How can I bind together two Java classes? I'm programming a 3D opengl program
I have an ObservableCollection that I want to bind to my listbox... lbRosterList.ItemsSource =
I want to implement functionality similar to Fiddler. I have tried 2 solutions: HttpListener
Have tried to find solutions for this and can't really come up with anything.
I have tried unsuccessfully to copy the pwd to pbcopy as follows pwd |

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.