Upon pressing a button a rectangle should be drawn on the second layer of my canvases and it should stay there. The drawing works, the staying does not. The rectangle appears for an instant, but immediately disappears again, and I cannot figure out why. Rectangles that I draw upon mouse actions with event listeners stay...
<html>
<body>
<h2>Raumaufteilung a: </h2>
<form action="" id="inputTactics">
<table border="1">
<tr><td><button id="Butt0" onclick="draw2()">Alle</button></td>
<td width="600" height="400" valign="top">
<div id="TacticsPic">
<canvas id="ground" width="525" height="340"
style="border:2px solid #ffffff; background-color: #23D419; position: absolute; z-index: 0">
</canvas>
<canvas id="c2" width="525" height="340"
style="position: absolute; z-index: 1">
</canvas>
<canvas id="c3" width="525" height="340"
style="position: absolute; z-index: 2">
</canvas>
<br>
</div>
</td>
</tr>
</table>
</form>
<script>
var canvasTac = document.querySelector("#c2");
var ctxTac = canvasTac.getContext('2d');
function draw2() {
ctxTac.strokeRect(100,100,250,100);
};
</script>
</body>
</html>