I am able to acquire the zindex value by useing the following code:
findHighestZIndex('div');
function findHighestZIndex(elem)
{
var elems = document.getElementsByTagName(elem);
var highest = 0;
for (var i = 0; i < elems.length; i++)
{
var zindex=document.defaultView.getComputedStyle(elems[i],null).getPropertyValue("z-index");
if ((zindex > highest) && (zindex != 'auto'))
{
highest = zindex;
}
}
return highest;
}
The problem is it is coming back at 9999, and I want to see what the name of the div or img or src of the zindex that has that value. I am then going to change the zindex value to something lower so I can put something in front of it.
I have not been able to find any attempts at searching by zindex and then getting src.
Based on your code return the element, not the zIndex from your function. Then you can simply grab the zIndex the src and the name from the element and do whatever with it.
var ele = findHighestZIndex('div'),
zIndex = ele.style.zIndex,
{src, name} = ele;
console.log(zIndex, src, name); // will log all the props
function findHighestZIndex(elem)
{
var elems = document.getElementsByTagName(elem);
var highest = 0;
for (var i = 0; i < elems.length; i++)
{
var zindex=document.defaultView.getComputedStyle(elems[i],null).getPropertyValue("z-index");
if ((zindex > highest) && (zindex != 'auto'))
{
highest = elems[i];
}
}
return highest;
}