日期:2014-05-16  浏览次数:20345 次

当multiple为true时,listbox选项交换的问题。
有代码:
JScript code

  function move() {
            var sel = document.getElementById("List");
            if (sel.options.length > 0 && sel.selectedIndex != -1) {
                var node = sel.options[sel.selectedIndex];
                var nextNode;
                if (sel.selectedIndex == 0)
                        nextNode = null;
                    else
                        nextNode = sel.options[sel.selectedIndex - 1];
               if (nextNode) node.swapNode(nextNode); //移动
            }
        }


HTML code

<select size="2" style="height: 203px; width: 309px" id="List" multiple="multiple">
        <option>a</option>
        <option>b</option>
    </select>
    <input type="button" value="up" onclick="move()">


在IE9中,当选中list的第二项时,点"up"按钮,会发现b项要很久时间才能移到前一个位置。如果去掉 multiple="multiple",则移动速度很快。大家有没遇到过这情况?

------解决方案--------------------
IE9 很快啊没遇到这种情况