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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:48:28+00:00 2026-05-28T14:48:28+00:00

When removing the selected attribute from options in a multiselect using .removeAttr(selected), the options

  • 0

When removing the “selected” attribute from options in a multiselect using .removeAttr(“selected”), the options are not immediately redrawn in Chrome as being unselected. Monitoring the DOM using Chrome Developer Tools shows that the selected attribute is removed from the DOM, but the options still appear to be selected until another item on the page is given focus.

Is there a way to get the options to redraw programmatically? I’ve triggering “change” and some other events, but nothing seems to work besides have the user hover or click in an appropriate place. It seems as if the browser forgets to redraw the elements until something else grabs its attention.

Here’s the relevant code:

$("#selectAll").click(function () {
    $("#x option").attr("selected", "selected");
});
$("#deselectAll").click(function () {
    $("#x option").removeAttr("selected");
});

And markup:

<a id="selectAll" href="javascript:void(0)">Select All</a>
<a id="deselectAll" href="javascript:void(0)">Deselect All</a>

<select multiple="multiple" size="5" style="height: 6em;" name="x" id="x">
     <option>1</option>
     <option>2</option>
     <option>3</option>
     <option>4</option>
     <option>5</option>
 </select>

This is in jQuery 1.7.1 and Chrome 16.

  • 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-28T14:48:29+00:00Added an answer on May 28, 2026 at 2:48 pm

    Set the focus on it and immediately call blur it works. Try this.

    $("#selectAll").click(function () {
        $("#x option").attr("selected", "selected");
    });
    $("#deselectAll").click(function () {
        $("#x").find("option")
        .removeAttr("selected")
        .end().focus().blur();
    });
    

    Demo

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

Sidebar

Related Questions

After removing hash from URL using window.location.hash='' page getting reloaded in firefox. EDIT Example:
I'm removing a component from the WindowedApplication, using removeChildAt(), and want to play an
I'm having difficulties removing the lineStyle lines in JTrees using Netbeans. In a standalone
I'm removing an item from an array if it exists. Two ways I can
How do i dynamically removing/adding(cancel the removal) form area using region and graphics path
$('<option selected=selected>something</option>') .removeAttr('selected') .wrap('<p></p>').parent().html(); results in <option>something</option> which is expected. But if I put
I have a select box, from which I want to remove selected choice with
I am working on a business application which is being developed from scratch. We
I want to do a control for adding and removing items from a two
I have problem removing rows from a table according to the checkbox. Below is

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.