Don't have .val() return selected-but-disabled options, or selected options inside...
[jquery.git] / src / attributes.js
index 73dee36..a76695b 100644 (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