I can move one image by define for each but I need to do it in for loop, I have a code as I show below,
var elem = document.querySelectorAll(".yikama");
var el;
for (i = 0; i = elem.length; i++)
{
var el = elem[i]
el.addEventListener("mousedown", start)
function start() {
addEventListener("mousemove", move)
}
function move(b) {
b = b || event;
el.style.left = b.pageX - 290 + "px";
el.style.top = b.pageY - 190 + "px";
}
el.addEventListener("mouseup", function () {
removeEventListener("mousemove", move);
})
}
But I had an error which is Uncaught TypeError: Cannot read property 'addEventListener' of undefined at 1:141 What should I do to fix it?