diff options
author | John Resig <jeresig@gmail.com> | 2007-07-08 16:28:45 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-07-08 16:28:45 +0000 |
commit | 6f0c9a5fd751d590be07e890758b8229e630413d (patch) | |
tree | 093fd3590b4c95a05538d2392adf34261baa2c81 | |
parent | 52c6739c20838f2d705d404664dcc0cfa07f2c30 (diff) | |
download | jquery-6f0c9a5fd751d590be07e890758b8229e630413d.tar.gz jquery-6f0c9a5fd751d590be07e890758b8229e630413d.zip |
Added support for "first option is auto-selected in a drop-down" functionality.
-rw-r--r-- | build/runtest/env.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/build/runtest/env.js b/build/runtest/env.js index f4c54bb4b..23b413640 100644 --- a/build/runtest/env.js +++ b/build/runtest/env.js @@ -305,6 +305,27 @@ var window = this; set checked(val) { return this.setAttribute("checked",val); }, get selected() { + if ( !this._selectDone ) { + this._selectDone = true; + + if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) { + var opt = this.parentNode.getElementsByTagName("option"); + + if ( this == opt[0] ) { + var select = true; + + for ( var i = 1; i < opt.length; i++ ) + if ( opt[i].selected ) { + select = false; + break; + } + + if ( select ) + this.selected = true; + } + } + } + var val = this.getAttribute("selected"); return val != "false" && !!val; }, |