Choose DIV with highest z-index
Sample code, so I can start explaining this problem:
<div style="z-index:5">5</div>
<div style="z-index:2">2</div>
<div style="z-index:1">1</div>
<div style="z-index:4">4</div>
<div style="z-index:3">3</div>
(z-index values do not matter, and their order is even less. Just a code example)
Problem: I want to select (using CSS or JS with jQuery) the DIV with the highest z-index value. In the above case, I want to select the first, because the z-index 5 is higher than all other z-indices.
Is there any way to do this? Additional info: I am writing Simple Window Manager with jQuery + jQuery UI, and z-indexes are assigned by the stack option in .draggable. I can't seem to find a way to get jQuery to assign the last drag and drop element to the class, so I am switching to the highest z-index. Any help please? Thanks.
I'm sure you could use a stop event to access a newly dragged item, i.e.:
$('.selector').draggable({
stop: function(event, ui) {
$(event.target).addClass('justDragged');
}
});
If you want to see all the functions / variables associated with the event, you can use the following:
var str = '';
for (i in event) {
str += i + ', ';
}
alert(str);
This should give you a good idea of what is available to you in any number of jQuery callback parameters.