У меня есть HTML-страница, как показано ниже:
<table cellpadding="1" cellspacing="1" border="1">
<tr>
<td id="abc">
<div style="height: 23px; overflow: hidden; position: relative; height: 70px; width: 70px;
background-color: red" valign="top" id="dragable3">
<a style="color: white" class="CalendarPlus-Item-2010311422" title="" href="#"><font
color="white">New Item</font></a></div>
</td>
<td>
<div id="4" style="width: 80px; height: 80px;">
</td>
<td>
<div id="5" style="width: 80px; height: 80px;">
</td>
</tr>
<tr>
<td>
<div id="8" style="width: 80px; height: 80px;">
</td>
<td>
<div id="7" style="width: 80px; height: 80px;">
</td>
<td>
<div id="6" style="width: 80px; height: 80px;">
</td>
</tr>
</table>
и jquery.js и файл javascript:
var DragHandler = {
// private property.
_oElem: null,
// public method. Attach drag handler to an element.
attach: function(oElem) {
oElem.onmousedown = DragHandler._dragBegin;
return oElem;
},
// private method. Begin drag process.
_dragBegin: function(e) {
var oElem = DragHandler._oElem = this;
if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }
var x = parseInt(oElem.style.left);
var y = parseInt(oElem.style.top);
e = e ? e : window.event;
oElem.mouseX = e.clientX;
oElem.mouseY = e.clientY;
document.onmousemove = DragHandler._drag;
document.onmouseup = DragHandler._dragEnd;
return false;
},
// private method. Drag (move) element.
_drag: function(e) {
var oElem = DragHandler._oElem;
var x = parseInt(oElem.style.left);
var y = parseInt(oElem.style.top);
e = e ? e : window.event;
oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';
oElem.mouseX = e.clientX;
oElem.mouseY = e.clientY;
return false;
},
// private method. Stop drag process.
_dragEnd: function() {
document.onmousemove = null;
document.onmouseup = null;
DragHandler._oElem = null;
},
_onPostBack: function(form, ehandle, arg) {
var theForm = document.forms[form];
if (!theForm) {
theForm = document.aspnetForm;
}
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = ehandle;
theForm.__EVENTARGUMENT.value = arg;
theForm.submit();
}
}
}
DragHandler.attach(document.getElementById('dragable3'));
Как мне получить Элемент под div (id = "dragable3"), который перемещается. Пример: я переместил тег div (id = "dragable3") из тега td (id = abc) в тег div (id = "6"). Как мы можем получить тег div (id = "6") после mouseup?
Спасибо,
Фонг Данг.