Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging overlapped images z-index with jQuery
    primarykey
    data
    text
    <p>I have three rectangular images overlapped within a diagonal line, the first fully visible on the top-left corner, the second in the center partially hidden by the first and the last in the bottom-right corner partially hidden by the second. I want the image which is clicked to go on top of the others. I'm trying to achieve this by manipulating z-index with jQuery but it doesn't seem to work. It actually seems like jQuery isn't even recognized.</p> <p>This is my test code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"&gt; $(document).ready(function () { $('#launch').click(function () { alert('Ok'); }); $('.bottom-pic').click(function () { $(this).css('z-index' : '1'); $('.bottom-pic').not(this).css('z-index' : '0'); }); }); &lt;/script&gt; &lt;style type="text/css"&gt; #pictures { width: 650px; height: 300px; margin-left: auto; margin-right: auto; margin-top: 20px; margin-bottom: 50px; position: relative; } #top { top: 0; left: 0; position: absolute; z-index: 1; } #center { top: 60px; left: 200px; position: absolute; z-index: 1; } #bottom { top: 150px; left: 400px; position: absolute; z-index: 0; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="pictures"&gt; &lt;img src="bottom-pic.jpg" id="top" class="bottom-pic"&gt; &lt;img src="bottom-pic.jpg" id="center" class="bottom-pic"&gt; &lt;img src="bottom-pic.jpg" id="bottom" class="bottom-pic"&gt; &lt;/div&gt; &lt;input type="button" value="Try" id="launch"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Still when I click the "launch" button nothing even happens.</p>
    singulars
    1. This table or related slice is empty.
    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