1

I have layered 4 canvases over the top of each over, however i want to be able to click a button and the linked canvas will come to the top.

http://jsfiddle.net/5g3Fe/ shows what i have currently got. I tried to put the following code into the button click functions. however this doesn't work.

function canvasView1()
{
document.getElementById("canvas1").style.z-index="1";
document.getElementById("canvas2").style.z-index="0";
document.getElementById("canvas3").style.z-index="0";
document.getElementById("canvas4").style.z-index="0";

}

can anyone suggest a way to be able to get specific canvas from a button click.

Thanks

Mark
  • 15
  • 1
  • 3

1 Answers1

0

For some reason, jsFiddle was ignoring your JavaScript code because of this reason. You can get around that by choosing No wrap - in <body> on the left hand side options.

Then your problem was that to set the z-index in javascript you use .style.zIndex rather than .style.z-index.

Working fiddle here

Or cleaner code version here

Community
  • 1
  • 1
Andy
  • 14,427
  • 3
  • 52
  • 76