I'm trying to make the circle I've made in canvas have an onclick event. I tried the following with no success. If anyone can offer some pointers, that would be great.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="type"></div>
<canvas id="ctx2" width="500" height="500" style="border: solid 1px;"></canvas>
<script>
var ctx = document.getElementById("ctx2").getContext("2d");
//var message = 'Hello John, this is your canvas.';
//ctx.fillStyle = 'red';
//ctx.font = '30px Arial';
//ctx.opacity = 0;
//ctx.fillText(message,50,50);
ctx.beginPath();
ctx.arc(100,75,50,0,2*Math.PI);
ctx.stroke();
ctx.onclick = displayDate(); // This is what I used (stack overflow)
function displayDate() {
document.getElementById("type").innerHTML = Date();
}
document.getElementById("type").innerHTML = typeof ctx
</script>
</body>
</html>