Return the z-index property value of an <img> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:zIndex

Description

Return the z-index property value of an <img> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<h1>This is a Heading</h1>

<img id="img1" src="http://java2s.com/resources/c.png" style="position:absolute;left:0px;top:0px;z-index:-1;width:100px;height:180px;">

<button type="button" onclick="myFunction()">Alert stack order</button>

<script>
function myFunction() {//w  w w.  jav  a2 s.  c om
    console.log(document.getElementById("img1").style.zIndex);
}
</script>

</body>
</html>

Related Tutorials