这个提交包含在:
Sahel Olivan 2022-12-09 10:50:46 +01:00
父节点 2f198a994c
当前提交 0efd5b1755
共有 3 个文件被更改,包括 74 次插入44 次删除

查看文件

@ -2,8 +2,8 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="Javascript" href="Page1.js">
<link rel="stylesheet" href="Puissance4.css" type="text/css">
<script type="text/javascript" src="Puissance4.js" defer></script>
<html>
<head>
<title>Puissance 4</title>
@ -21,19 +21,64 @@
</header>
<main>
<section>
<article>
<div id="Puissance4Board">
<div class="one">1</div>
<div class="two">2</div>
<div class="three">3</div>
<div class="four">4</div>
<div class="five">5</div>
<div class="six">6</div>
</div>
</article>
<table id="Board">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</section>
</main>
<footer>&copy; Copyright 2019 by ME. All Rights Reserved.</footer>
<footer>&copy; Copyright 2022 by Sahel Olivan. All Rights Reserved.</footer>
</body>
</html>

查看文件

@ -1,8 +1,17 @@
var currentRow = 0;
var currentColumn = 0;
const tbody = document.querySelector('#Board');
tbody.addEventListener('click', function (e) {
const cell = e.target.closest('td');
if (!cell) {return;} // Quit, not clicked on a cell
const row = cell.parentElement;
console.log(cell.innerHTML, row.rowIndex, cell.cellIndex);
});
tbody.addEventListener('click', function (e){
const cell = e.target.closest('td');
if (!cell) {return;}
const row = cell.parentElement;
currentRow = row.rowIndex;
currentColumn = cell.cellIndex;
test();
});
function test(){
console.log(currentRow, currentColumn);
}

查看文件

@ -62,30 +62,6 @@ footer{
gap: 1em;
padding: 1em;
}
.one{
grid-column: 1;
grid-row: 1;
}
.two{
grid-column: 1;
grid-row: 1;
}
.three{
grid-column: 1;
grid-row: 1;
}
.four{
grid-column: 1;
grid-row: 1;
}
.five{
grid-column: 1;
grid-row: 1;
}
.six{
grid-column: 1;
grid-row: 1;
}
#RegleMorp{
background-color: lightgrey;
text-align: center;