Don't have .val() return selected-but-disabled options, or selected options inside a disabled optgroup. Doesn't change the .val() returned for a disabled select. Fixes #3240, adapted from Nathan Hammond's patch there.

This commit is contained in:
Dave Methvin 2010-09-24 17:26:22 -04:00 committed by jeresig
parent 700ff05af0
commit 2c4b20809e
6 changed files with 31 additions and 12 deletions

View file

@ -163,8 +163,10 @@ jQuery.fn.extend({
for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
var option = options[ i ];
if ( option.selected ) {
// Get the specifc value for the option
// Don't return options that are disabled or in a disabled optgroup
if ( option.selected && !option.disabled &&
(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
// Get the specific value for the option
value = jQuery(option).val();
// We don't need an array for one selects