I've been holding onto this question for quite some time, hesitant to ask because of potential backlash. Nevertheless, here I am finally sharing my dilemma in hopes of finding a solution...
Imagine there's an element on the page that can be dragged with the ID "dragme"... Now, instead of manually dragging it to a specific location every time, is there a way to automate this task using a function? Let's call this function "dropElement". Essentially, I want to simulate dragging "dragme" to wherever my mouse cursor is positioned using a script in jQuery or JavaScript.
This is what I've attempted so far:
(function() {
'use strict';
var mouseX = 0;
var mouseY = 0;
var timer = 0;
document.body.addEventListener("mousemove", function(e) {mouseX = e.clientX; mouseY = e.clientY;});
function dropElement() {
$("#dragme").trigger($.Event("mousedown", {button: 0}));
$("body").trigger($.Event("mouseup", {button: 0, clientX: mouseX, clientY: mouseY}));
timer = setTimeout(dropElement, 100);
}
dropElement(); // executes function and drops "dragme" to mouse position