站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题JS获取被拖动的对象的ID

JS获取被拖动的对象的ID

摘要: JS获取被拖动的对象的ID
<tr> <td>

HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<head>
New Document




</head>

<body>
<script LANGUAGE="JavaScript">

function movemouse(e)
{
if (isdrag)
{
dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
return false;
}
}

function selectmouse(e)
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";
while (fobj.tagName != topelement && fobj.className != "dragme")
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}
if (fobj.className=="dragme")
{
isdrag = true;
dobj = fobj;
//alert(dobj.id);显示被拖动图片的ID
ty = parseInt(dobj.style.top+0);
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
//
</script>




</body>

</td> </tr> </table>
↑返回目录
前一篇: 人工生命—群集智能—蚁群算法js版
后一篇: JS实现图片无缝滚动的完美解决