ドラッグ可能にする

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/prototype.js" charset="shift_jis"></script>
<script type="text/javascript" src="js/scriptaculous.js" charset="shift_jis"></script>
<script type="text/javascript"><!--
Event.observe(window, "load", function(){
new Draggable("content");
new Draggable("photo001", {
constraint : "horizontal"
});
new Draggable("photo002", {
snap : function(x,y){
return [ Math.floor(x / 20)*20, Math.floor(y / 20)*20];
}
});
}, false);
// --></script>
</head>
<body>
<h1>ドラッグ可能にする</h1>
<div id="content">ここがドラッグできます</div>
<img src="images/photo1.jpg" width="96" height="54" alt="高原" id="photo001">
<img src="images/photo2.jpg" width="96" height="54" alt="牡丹" id="photo002">
</body>
</html>
サンプルを実行
[戻る]
prototype.jsパーフェクトリファレンス説明などは本書を参考にしてください。