How to swap a disabled option DOM element to enabled?


I have a list with enabled and disabled option. I do know how to disable an option element but what I don't know how to enable it again.

<select size="1" id="x"> <option value="47" disabled="disabled">Value 47</option> ... selectElement.options[i].disabled = 'disabled'; // ... how to enable?

It should be done with Plain Javascript and no JavaScript Framework. (I wish I could use Prototype or a similar framework but I cannot introduce one of them.)


Use <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-F68F082" rel="nofollow">setAttribute</a> and <a href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-6D6AC0F9" rel="nofollow">removeAttribute</a>:

selectElement.options[i].setAttribute("disabled", "disabled"); selectElement.options[i].removeAttribute("disabled");


The DOM object's <em>property</em> is a boolean value, that should be set to true or false:

selectElement.options[i].disabled = false;

Also see <a href="https://stackoverflow.com/questions/706384/boolean-html-attributes" rel="nofollow">Boolean HTML Attributes</a>.


  • Adding 9000 options dynamically to select in javascript taking too long on IE
  • How to select an option from dropdown list by matching text pattern using selenium webdriver and jav
  • Jest not auto mocking common js modules
  • How to check if DIV element is disabled using jquery
  • IE11 textarea loses focus if another textarea is disabled
  • How can I reset dropdown data if modal closed on vue component?
  • How can I let users share their location in Bot Framework webchat channel?
  • HttpURLConnection Closing IO Streams
  • How to 'create temp table as select' in Slick?
  • How to getText() from the input field of an angularjs Application
  • How to make jdk.nashorn.api.scripting.JSObject visible in plugin [duplicate]
  • How does document.ready work with angular element directives?
  • Zurb Foundation _global.scss meta styles for js?
  • jQuery ready not fired after rails link_to is clicked
  • Parsing a CSV string while ignoring commas inside the individual columns
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • Change multiple background-images with jQuery
  • Android screen density dpi vs ppi
  • Deleting and Updating values from a cusrsor adapter
  • HTML download movie download link
  • Updating server-side rendering client-side
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Modifying destination and filename of gulp-svg-sprite
  • 'TypeError' while using NSGA2 to solve Multi-objective prob. from pyopt-sparse in OpenMDAO
  • Change an a tag attribute in JavaScript based on screen width
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How to set the response of a form post action to a iframe source?
  • How do you join a server to an Active Directory (domain)?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • How to stop GridView from loading again when I press back button?
  • How does Linux kernel interrupt the application?
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?