Return the z-index property value of an <img> element:
alert(document.getElementById("img1").style.zIndex);
<!DOCTYPE html> <html> <body> <h1>This is a Heading</h1> <img id="img1" src="image3.png" style="position:absolute;left:0px;top:0px;z-index:-1;width:100px;height:180px;"> <button type="button" onclick="myFunction()">Alert stack order</button> <p>Default z-index is 0. Z-index -1 has lower priority.</p> <p id="demo"></p> <script> function myFunction() {/*from w w w.j ava 2s .c o m*/ document.getElementById("demo").innerHTML = document.getElementById("img1").style.zIndex; } </script> </body> </html>