diff --git a/js/index.mjs b/js/index.mjs index f053f55..a47aacf 100644 --- a/js/index.mjs +++ b/js/index.mjs @@ -50,9 +50,12 @@ async function createBlocks(dat) { div.onclick = function (e) { if (clickedBlock) { if (clickedArea != dat) { + let next1 = clickedBlock.nextSibling; + let next2 = div.nextSibling; + let p = clickedBlock.parentElement; - div.parentElement.appendChild(clickedBlock); - p.appendChild(div); + div.parentElement.insertBefore(clickedBlock,next2); + p.insertBefore(div,next1); let swap = {}; console.log(clickedArea, dat)