html5 拖动问题

dys_198102 2012-06-02 10:53:07
在网上看到说的资料说html5可以拖动。但我无论怎么弄都不行。高人指点
<script language="javascript" src="js/jquery-1.4.2.min.js"></script>
<script language="javascript">
function asd()
{
document.ondragover = function(e){

e.preventDefault();

};

document.ondrop = function(e){

e.preventDefault();

};
}
</script>
</head>

<body onLoad="asd()">
<div draggable=”true” id="a">adfadsfadfadfadfadfadafads</div>
</body>
</html>
...全文
195 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
弘毅致远 2012-06-05
  • 打赏
  • 举报
回复
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.7.2.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script>
<script src="../../ui/jquery.ui.draggable.js"></script>
<link rel="stylesheet" href="../demos.css">
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>
<script>
$(function() {
$( "#draggable" ).draggable();
});
</script>
</head>
<body>

<div class="demo">

<div id="draggable" class="ui-widget-content">
<p>Drag me around</p>
</div>

</div><!-- End demo -->



<div class="demo-description">
<p>Enable draggable functionality on any DOM element. Move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport.</p>
</div><!-- End demo-description -->

</body>
</html>
弘毅致远 2012-06-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

可以做成像窗口一样随意拖动吗?
[/Quote]
请参考
弘毅致远 2012-06-05
  • 打赏
  • 举报
回复
有一点点拖拉的效果,但不能移动。楼主javascript有点问题,注意引号。
<div draggable=”true” id="a">adfadsfadfadfadfadfadafads</div>

dys_198102 2012-06-03
  • 打赏
  • 举报
回复
可以做成像窗口一样随意拖动吗?
001007009 2012-06-02
  • 打赏
  • 举报
回复
楼主 什么浏览器测试的?

html5 需要 在 firefox chrome 等 标准浏览器跑。


参考下,很详细。
http://www.zhangxinxu.com/wordpress/?p=1419

61,126

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧