-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove.html
37 lines (33 loc) · 948 Bytes
/
remove.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<style>
table, td { border: 1px solid black;}
</style>
</head>
<body>
<table id ="t">
<tr><td>(1,1)</td><td>(1,2)</td></tr>
<tr><td>(2,1)</td><td>(2,2)</td></tr>
</table>
<button onclick="insert()">추가</button>
<button onclick="removet()">제거</button>
<script>
let count=3;
function insert(){
let table = document.getElementById("t");
let row = table.insertRow(-1);
let cell1 = row.insertCell(0);
let cell2 = row.insertCell(1);
cell1.innerText = "("+count+",1)";
cell2.innerText = "("+count+",2)";
count++;
}
function removet(){
let table = document.getElementById("t");
let row = table.deleteRow(-1);
count--;
}
</script>
</body>
</html>