28 lines
827 B
JavaScript
Raw Normal View History

2020-02-12 17:01:08 +01:00
console.log("Chargement...");
function init() {
console.log("Initialisation...");
2020-02-12 17:25:20 +01:00
var div = document.querySelectorAll(".case");
2020-02-12 17:01:08 +01:00
for (var i = 0; i < div.length; i++) {
div[i].addEventListener("click", selection);
}
}
function selection(event) {
2020-02-12 17:25:20 +01:00
var maCase = event.currentTarget;
var vide = document.body.querySelector(".case.vide");
if ((maCase.offsetTop == vide.offsetTop && Math.abs(maCase.offsetLeft - vide.offsetLeft == 102)) ||
2020-02-12 18:36:12 +01:00
(maCase.offsetLeft == vide.offsetLeft && Math.abs(maCase.offsetTop - vide.offsetTop == 102))) {
console.log("1");
maCase.className = "case vide";
vide.className = "case";
}
console.log(event.currentTarget.className + " : " + event.currentTarget.innerText);
var e = event.target;
}