git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jquery core: closes #2652. val() supports option elements, also simplified the code.
[jquery.git]
/
src
/
core.js
diff --git
a/src/core.js
b/src/core.js
index
c095f74
..
74fd6fc
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-362,6
+362,9
@@
jQuery.fn = jQuery.prototype = {
if ( this.length ) {
var elem = this[0];
if ( this.length ) {
var elem = this[0];
+ if( jQuery.nodeName( elem, 'option' ) )
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+
// We need to handle select boxes special
if ( jQuery.nodeName( elem, "select" ) ) {
var index = elem.selectedIndex,
// We need to handle select boxes special
if ( jQuery.nodeName( elem, "select" ) ) {
var index = elem.selectedIndex,
@@
-379,7
+382,7
@@
jQuery.fn = jQuery.prototype = {
if ( option.selected ) {
// Get the specifc value for the option
if ( option.selected ) {
// Get the specifc value for the option
- value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
+ value = jQuery(option).val();
// We don't need an array for one selects
if ( one )
// We don't need an array for one selects
if ( one )