드래그 한 요소를 놓는 순간에 마우스를 올려 놓은 요소를 어떻게 얻을 수 있습니까?
컨테이너의 모든 요소에는 공통적으로 .droppableYElement 클래스가 있습니다.
$("#container").droppable({
accept: ".droppableXElement",
activeClass: "ui-state-hover",
hoverClass: "ui-state-active",
drop: function (event, ui) {
alert("I am dropped");
// How can I get the element which I hovered at the moment of dropping the dragged element?
}
});
이것을보십시오 : http://jsfiddle.net/lotusgodkk/GCu2D/528/
JS :
$(document).ready(function () {
$("#itemContainer > div").each(function (index, element) {
$(element).draggable();
});
$("#itemContainer").droppable({
activeClass: "ui-state-hover",
hoverClass: "ui-state-active",
drop: function (event, ui) {
var element = document.elementFromPoint(event.pageX, event.pageY);
//Get the coordinates of mouse and using these coordinates, find the element.
console.log(element); //Element which was hovered.
}
});
});
도움이 되었기를 바랍니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다