[問題] javascript 拖拉圖片
請問如果希望可以拖拉網頁上的圖片 各位會怎麼作
function down(){
mouseDown=true;
x=event.x;
y=event.y;
}
function move(){
if(mouseDown==true){
document.getElementById("pos").style.left+=(event.x-x);
document.getElementById("pos").style.top+=(event.y-y);
//alert(x+" "+y+" "+event.x+" "+event.y);
}
}
function up(){
mouseDown=false;
}
我想到的方法是把mouseDown時 設一個flag
move時 style的position跟著改變
但是圖片仍無法動
<div id="pos" style="position:absolute;left:0px;right:0px">
<img src="a.bmp" onmousedown=down() onmouseup=up() onmousemove=move()>
</div>
請問是哪裡出問題了 非常謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.69.86
推
04/13 00:38, , 1F
04/13 00:38, 1F
→
04/13 00:39, , 2F
04/13 00:39, 2F
推
04/13 00:44, , 3F
04/13 00:44, 3F
→
04/13 00:45, , 4F
04/13 00:45, 4F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 4 篇):