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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:30:51+00:00 2026-06-15T20:30:51+00:00

I want to remove the selected attribute from an option element when I uncheck

  • 0

I want to remove the “selected” attribute from an option element when I uncheck this. I dont want to make value false or anything… I just want to delete this property. My code is like

$(function() {
  $("#deployselect").multiselect({
    click: function( event, ui ) {
      if(ui.checked==false){
        $("#deployselect option[value='"+ui.value+"']").removeAttr("selected");
      }
    }
  });
});

My generated HTML is like this

<option value="68" selected>A1</option>
<option value="49" selected>A2</option>
<option value="69" selected>A3</option>

so even i make “attr” or “prop” false it is not working. 🙁

  • 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-15T20:30:53+00:00Added an answer on June 15, 2026 at 8:30 pm

    If you want to de-select it, change this line:

    $("#deployselect option[value='"+ui.value+"']").removeAttr("selected");
    

    to

    $("#deployselect option[value='"+ui.value+"']").prop("selected", false);
    

    Live Example | Source

    (Assuming jQuery 1.6 or later; for earlier versions, change prop to attr.)

    Once the HTML has been parsed into the DOM, the option element has a property called selected which gets its initial value from the selected attribute in the HTML (defaulting to false). So once you’re dealing with DOM elements, you’re dealing with a boolean property, not an attribute anymore.

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

Sidebar

Related Questions

I want to remove user-selected elements from an XML list, using element indexes. For
i want to remove the link from my header using CSS so that only
I want to remove duplicate lines from a file, without sorting the file. Example
I want to remove a key from a dictionary if it is present. I
I want to remove an item from ListView , but I don't know how
Just want to remove highlight class before applying class again on other elements. Reseting
I have a problem... I tried to remove the selected items from dijit.form.MultiSelect when
I have the following: <dd> <select id=contactLocation name=contactLocation size=1> <option value=Online<cfif attributes.contactLocation eq Online>selected</cfif>>Online</option>
I want to remove sub elements from an XML doc using LINQ to XML.
I want to remove this class on checkbox toggle. $(#checkbox).toggle(function () { var it0

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.