javascript - IE returns wrong z-index -


so here z-index issue in ie7 have ran into. found explanation of problem else without fix.

when have positioned element inline z-index of 0, javascript doesn't return correct z-index. if z-index set element in stylesheet return z-index instead. same result using jquery too.

make html file following:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script type="text/javascript">    $(function(){       $('button').click(function(){          alert($('#mainbox').css('zindex'));       });    }); </script> <style type="text/css">    #mainwr {       position: relative;       z-index: 2;       border: 1px solid #333;       width: 200px;       height: 200px;    }    #mainbox {       z-index: 1;       border: 1px solid #555;       width: 100px;       height: 100px;       position: absolute;       top: 50px;       left: 50px;    }  </style>  <div id="mainwr">    <div id="mainbox" style="z-index: 0;"></div> </div> <br /> <button type="button">show #mainbox z-index</button> 

open in ie7. problem not exist in ie8.

i jsfiddled if have ie7, otherwise need use code , display whatever method use emulate ie7:

http://jsfiddle.net/dalelarsen/dndnm/

i not aware of solutions. comments welcome.

if not mistaken providing negative z-index resolves issue. developer here ran issue , believe resolution.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -