Commit 6f0c9a5f authored by John Resig's avatar John Resig

Added support for "first option is auto-selected in a drop-down" functionality.

parent 52c6739c
...@@ -305,6 +305,27 @@ var window = this; ...@@ -305,6 +305,27 @@ var window = this;
set checked(val) { return this.setAttribute("checked",val); }, set checked(val) { return this.setAttribute("checked",val); },
get selected() { 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"); var val = this.getAttribute("selected");
return val != "false" && !!val; return val != "false" && !!val;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment