Hello
I am having trouble getting "event.target.id" .
https://vmars.us/Guitar/Drag-Drop-Working-Multiple-28x28-Elements-K-CLONE-NOT-Working.html
Here is the script :
What am I doing wrong ?
Thanks for your Help...
I am having trouble getting "event.target.id" .
https://vmars.us/Guitar/Drag-Drop-Working-Multiple-28x28-Elements-K-CLONE-NOT-Working.html
Here is the script :
Code:
<script>
var elemNumber = 0;
var element = "";
var elem = "" ;
var hold_this_id = "" ;
// =================================================
document.addEventListener('contextmenu', fireContextMenu);
// This function will be called whenever contextmenu event occurs
function fireContextMenu(event) {
event.preventDefault();
hold_this_id = event.target.id; // Get ID of Clicked Element
/*
for(var i of document.querySelectorAll('img')){
i.addEventListener('contextmenu', function(event) {
return false;
}, false);
}
*/
// Get the element
var elem = hold_this_id ;
console.log("02 hold_this_id = " + hold_this_id);
//console.log(elem);
// Create a copy of it
var clone = elem.cloneNode(true); // statement 134
clone.addEventListener("dragstart", (event) => { drag(event); });
// Update the ID and add a class
clone.id = 'elem1' + elemNumber;
clone.draggable = 'true';
clone.onclick = "helloConsole()"
clone.zIndex = elemNumber;
elemNumber = elemNumber + 1
// Inject it into the DOM
hr01.after(clone);
//function cloneElem1()
}
// =================================================
</script>
What am I doing wrong ?
Thanks for your Help...