faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 31 people (74%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do you change the z-index of an element with Netscape 6

May 27th, 2000 08:07
Martin Honnen, Ken Daniels,


You set
  elementReference.style.zIndex = number
You need to know that
  elementReference.style.zIndex
returns a string so if you want to manipulate that value use
  elementReference.style.zIndex = 
     parseInt(elementReference.style.zIndex) + 1

Here is a complete example 

<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV STYLE="position: absolute;
            left: 100px; top: 100px;
            width: 100px; height: 100px;
            background-color: orange;
            z-index: 10;"
     ONCLICK="this.style.zIndex = parseInt(this.style.zIndex) + 5"
>
</DIV>
<DIV STYLE="position: absolute;
            left: 150px; top: 150px;
            width: 100px; height: 100px;
            background-color: lightblue;
            z-index: 8;"
     ONCLICK="this.style.zIndex = parseInt(this.style.zIndex) + 5"
>
</DIV>
</BODY>
</HTML>