This commit is contained in:
JunkJumper 2020-02-12 17:25:20 +01:00
parent 2d38d12955
commit 5017da42b5

View File

@ -3,16 +3,25 @@ console.log("Chargement...");
function init() { function init() {
console.log("Initialisation..."); console.log("Initialisation...");
var div = document.querySelectorAll('.case'); var div = document.querySelectorAll(".case");
for (var i = 0; i < div.length; i++) { for (var i = 0; i < div.length; i++) {
div[i].addEventListener("click", selection); div[i].addEventListener("click", selection);
} }
//console.log(grille);
} }
function selection(event) { function selection(event) {
console.log(event.currentTarget.tagName);
var e = event.target; var maCase = event.currentTarget;
} var vide = document.body.querySelector(".case.vide");
if ((maCase.offsetTop == vide.offsetTop && Math.abs(maCase.offsetLeft - vide.offsetLeft == 102)) ||
(maCase.offsetLeft == vide.offsetLeft && Math.abs(maCase.offsetTop - vide.offsetTop == 102)) {
maCase.setAttribute("class", ".case.vide");
vide.setAttribute("class", ".case");
}
console.log(event.currentTarget.innerText);
var e = event.target;
}