开始的代码,使用for循环来一个个监测是否被选中:function moveOption2(sourceSelect, destSelect){ var sourceOptions = sourceSelect.options; for(var i=sourceOptions.length-1; i>-1; i--){ var option = sourceOptions[i]; if(option.selected){ var newOption = new Option(option.text, option.value); destSelect.add(newOption); sourceSelect.remove(i); destSelect.scrollIntoView(false); } }}优化后的代码,只检查被选中的代码,巧妙的使用了selectedIndex的特性:function moveOpti阅读全文>
发表于 @ 2008年11月12日 17:06:00|评论(loading...)|举报|收藏