Created
April 2, 2012 18:12
-
-
Save 3emad/2285936 to your computer and use it in GitHub Desktop.
Changing options position pitfall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* // the following example failed to keep the last index. | |
* | |
* temp = selElem.options[0]; | |
* selElem.options[0] = selElem.options[1]; | |
* selElem.options[1] = temp | |
* return; | |
*/ | |
var dash = selElem.options[0]; | |
var all = selElem.options[1]; | |
selElem.options[0] = new Option(all.value, all.innerHTML); | |
selElem.options[1] = new Option(dash.value, dash.innerHTML); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment