http://docs.jquery.com/Plugins上面罗列出了足够多的jquery插件。interface居首。
首先到http://interface.eyecon.ro/ 上下载包,最新版本是interface1.2(146K),足已证明这个插件的强大,但这里我们只要它的drag功能

html:
<html>
//首先在页面头部包含进插件资源
<head>
<script type="text/javascript" src="./common/compressed/idrag.js" ></script>
<script type="text/javascript" src="./common/interface.js" ></script>
</head>
<body>

//需要移动的层
<div id="wcc_form">
<span><div id="title">title</div></span>
<div id="content">content</div>
</div>

</body>
</html>

js:
jQuery('#wcc_form').Draggable({
        handle:    'span'
});
一行搞定,真的是写得少做得多

注意点:
jquery里绑定的div wcc_form都将是移动的块。但这里我不想整个层都是作用点。于是定了一个范围用span圈定,这样只有title部分才可以被拖动。如果在js 里不指定handle,作用域就是整个块了,呵呵,好玩。
posted on 2009-08-21 12:10  钱途无梁  阅读(981)  评论(0编辑  收藏  举报