2013-05-08 18 views

回答

1

試試這個代碼

$(document).ready(function(){ 
$('#drag').on('mousedown', function(e){ 
    var $dragable = $(this).parent(), 
     startWidth = $dragable.width(), 
     pX = e.pageX; 

    $(document).on('mouseup', function(e){ 
     $(document).off('mouseup').off('mousemove'); 
    }); 
    $(document).on('mousemove', function(me){ 
     var mx = (me.pageX - pX); 
     //var my = (me.pageY - pY); 

     $dragable.css({ 
      left: mx/2, 
      width: startWidth - mx, 
      //top: my 
     }); 
    }); 

}); 

});

See Demo

希望它可以幫助你

+1

不錯的演示,但他不問表列? – Nathan 2013-05-08 06:38:03

+0

不錯的演示:)它可以幫助我。 – 2013-05-08 06:50:00

+0

這就是很好的演示。但我希望在表格行上有鼠標雙箭頭標記,並且我應該可以向右或向左移動,這會自動增加/減少表格列的寬度。 – user1587872 2013-05-08 06:50:15