I am finding it hard to get my buttons working inside a html canvas. I think that the onclick event is not being called or the canvas is over layed and drawing over them but I can't figure out why. I have tried putting the buttons on a higher z-index as demonstrated here
Can I put an HTML button inside the canvas?
but I have had no avail. Here is the code for the canvas and button
<canvas id="whiteboard" style="z-index:1; position: absolute; left: 0px; top: 0px;"></canvas>
<input type="button" style="z-index: 2" value="blue" id="blue" onclick="colorChange('#0000FF');" />
here is the script tag
<script src="assets/js/color.js"></script>
and the function I am trying to call in color.js
function colorChange(color) {
alert("adadadsdasd");
var c = document.getElementById('whiteboard');
var ctx = c.getContext("2d");
ctx.fillStyle = color;
}
I am fairly new to JS so I apologise if there is any rookie errors.