JQuery ListBox间移动和ListBox内上下移动

代码
            var $btnUp = $('#ChooseUserControl1_btnUp');
            var $btnDown 
= $('#ChooseUserControl1_btnDown');
            
            
            
            
//选择的联系人上下移动///////////////////////////////////
            $btnUp.click(function()
            {
                $lbSelLinkMan.find(
'option:selected').each(function(index, item)
                {         
                    ListBox_Order(
'up'); 
                });
                
return false;
            });
            $btnDown.click(function()
            {
                $lbSelLinkMan.find(
'option:selected').each(function(index, item)
                {
                    ListBox_Order(
'down');
                });
                
return false;
            });
            function ListBox_Order(action)
            {                
                var size 
= $lbSelLinkMan.find('option').size();
                var selsize 
= $lbSelLinkMan.find('option:selected').size();
                
                
if (size > 0 && selsize > 0)
                {                    
                    $lbSelLinkMan.find(
'option:selected').each(function(index, item)
                    {
                        
if (action == "up")
                        {
                            $(item).prev().insertAfter($(item));
                            
return false;
                        }
                        
else if (action == "down")//down时选中多个连靠则操作没效果
                        {
                            $(item).next().insertBefore($(item));
                            
return false;
                        }
                    })
                }
                
return false;
            }

 

posted @ 2010-09-03 10:24  Magicam  阅读(411)  评论(0编辑  收藏  举报