Javascript examples for CSS Style Property:zIndex
The zIndex property sets or gets the stack order of a positioned element.
Value | Description |
---|---|
auto | The browser sets the stack order of the element. This is default |
number | sets the stack order of the element. Negative values are allowed |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | auto |
Return Value: | A String, representing the stack order of an element |
CSS Version | CSS2 |
Change the stack order of an <img> element:
<!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()">test</button> <script> function myFunction() {//from www. java 2 s .c o m document.getElementById("img1").style.zIndex = 2; } </script> </body> </html>