0

I have a page where I am using some plugins which are used to e.g. make a table header fixed. Now I have to show a div at top of the other div based on its z-index.

But the problem is that I have many dynamic divs like that so I cannot add a predefined z-index.

What I want to do is, when I add a div (by click on a button) at the top of another, I need to check the maximum z-index value (of visible divs) present in the window.

How can I achieve this?

Suppose I have 10 element in HTML page and each have z-index form 1 to 10 respectively, so when I click a button I need a JS code that return me 10 as I have a div with z-index = 10

z-index may be defined inline on div on in class as well, any suggestion ?

Thorin
  • 2,004
  • 1
  • 19
  • 30
  • grep your stylesheet(s). Take the maximum z-index and add a 0 (on the end) – Adam Jenkins May 11 '16 at 12:42
  • You want a means by which you can click on an element and then find the element with the highest `z-index` within that element? What happens if the element you click is contained within an ancestor, should it be limited to the element you clicked, or an ancestor element? What information do you want, the element, or its `z-index`? – David Thomas May 11 '16 at 12:42
  • Can you count the number of objects ordered by z-index with javascript? For example `document.getElementsByClassName('myClassHere').length` ? – Leo Napoleon May 11 '16 at 12:48
  • 5
    http://stackoverflow.com/questions/5680770/jquery-find-the-highest-z-index – dsdsdsdsd May 11 '16 at 12:57
  • here's a jquery plugin, `topzindex`: https://code.google.com/archive/p/topzindex/ – dsdsdsdsd May 11 '16 at 12:58

0 Answers0