Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery mouseover and z-index: what determines which element is on "top"?
    primarykey
    data
    text
    <p>I am working on a game that calls for a large map. What I do is set the big 12k x 12k pixel map in the background of a scrollable div (scrollWindow) with a z-index of 1.</p> <p>Later, an Ajax call returns some JSON data that adds a number of classes (City_Palace) inside of the large background map. The elements have z-index of 9.</p> <p>I also have a couple mouseover events set up that do different things based on whether the cursor is over the map in the background or over one of the cities draw on top of it. However, even though the z-index of the cities is much higher than that of the main window, the event never fires for the city mouseover because the scrollable window is on "top".</p> <p>What criteria is used for jquery to determine which div is on "top" when it comes to mouse events? It seems z-index is not it.</p> <p>Here is some code:</p> <p>CSS:</p> <pre><code>#scrollWindow { width: 1970px; height: 900px; overflow: scroll; border: solid black 3px; position: absolute; z-index:1; } .City_Palace { height: 20px; width: 20px; position: absolute; z-index: 9; background-image: url("../Images/City_Palace.png"); background-size: 100% 100%; } </code></pre> <p>Jquery:</p> <pre><code>$('.City_Palace').mouseover(function() { alert("city classes on top"); }); $("#scrollWindow").mousemove(function(e){ alert("scroll window on top"); }); </code></pre> <p>Here is how the HTML is generated:</p> <pre><code>&lt;div id="scrollWindow" class="ui-widget-content" style="width: 2105px;"&gt; &lt;img id="img" src="../Images/fullSizeMap.png"&gt; &lt;div class="City_Palace" value="coast" style="left: 780px; top: 540px;"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I'm guessing that somehow the child-parent relationship is overriding the z-index. Any suggestions on how I might fix this? Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload