Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

jQuery $('#id').val() should not return null for a "disabled selected" HTML select option #20

Open
tkrotoff opened this issue Nov 12, 2013 · 1 comment

Comments

@tkrotoff
Copy link
Owner

<select id="colorpicker">
  <option value="#7bd148">Green</option>
  <option value="#5484ed">Bold blue</option>
  <option value="#a4bdfc" selected disabled>Blue</option>
  <option value="#46d6db">Turquoise</option>
  <option value="#7ae7bf">Light green</option>
  <option value="#51b749">Bold green</option>
  <option value="#fbd75b">Yellow</option>
  <option value="#ffb878">Orange</option>
  <option value="#ff887c" selected disabled>Red</option>
  <option value="#dc2127">Bold red</option>
  <option value="#dbadff">Purple</option>
  <option value="#e1e1e1">Gray</option>
</select>

With jQuery

$('#colorpicker').val();

returns null

Without jQuery

// See How to get the selected value of dropdownlist using JavaScript? http://stackoverflow.com/questions/1085801/how-to-get-the-selected-value-of-dropdownlist-using-javascript
var e = document.getElementById('colorpicker');
e.options[e.selectedIndex].value;

returns "#ff887c"

@pavdro
Copy link

pavdro commented Jan 28, 2014

Just posting here in case anyone comes across the issue as well.
This is jQuery issue and not plugin.

http://bugs.jquery.com/ticket/13097

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants