因為我的dialog想要有拖曳功能,先寫一個drag的測試頁面吧
<style>
#drag {
cursor: move ;
position: absolute ;
}
</style>
<script>
$(function()
{
$(document)
.on('mousedown', '#drag', function(orgiE)
{
var self = $(this) ;
var _position = self.position() ;
var orgiLeft = _position.left ;
var orgiTop = _position.top ;
self
.mousemove(function(moveE)
{
self
.css(
{
left: orgiLeft + ( moveE.clientX - orgiE.clientX )
, top: orgiTop + (moveE.clientY - orgiE.clientY )
}) ;
}) ;
})
.on('mouseup', '#drag', function(e)
{
$(this).off('mousemove') ;
}) ;
}) ;
</script>
<div id='drag' style="width:100px;height:100px;background:gray;">test</div>
http://ry.url.tw/wp/doc/a17testDRAG.htm