Я рекомендую вам удалить все z-индексы из вашего css. Затем создайте класс с именем '.veryHighZ-Index, например, и добавьте этот класс в изображение, по которому щелкнули, и удалите класс из ранее нажатого изображения ...
Я немного изменил ваш код, но этот код здесь должен работать.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function () {
// #pictures div catches all divs inside the #pictures
$('#pictures div').click(function () {
$('.veryhighz-index').removeClass('veryhighz-index');
$(this).addClass('veryhighz-index');
});
});
</script>
<style type="text/css">
#pictures {
width: 650px;
height: 300px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
margin-bottom: 50px;
background: lime;
position: relative;
overflow: hidden;
}
#top {
top: 0;
left: 0;
position: absolute;
}
#center {
top: 60px;
left: 200px;
position: absolute;
}
#bottom {
top: 150px;
left: 400px;
position: absolute;
}
.top, .center, .bottom {
width: 300px;
height: 300px;
border: 2px solid red;
}
.top {background: red;}
.center {background: yellow;}
.bottom {background: blue;}
.veryhighz-index {
z-index: 999999;
}
</style>
</head>
<body>
<div id="pictures">
<div id="top" class="top"></div>
<div id="center" class="center"></div>
<div id="bottom" class="bottom"></div>
</div>
</body>
</html>
Короче говоря, добавьте следующий код к вашей CSS
.veryhighz-index {
z-index: 999999;
}
и этот код для функций JavaScript
// #pictures img catches all images inside the #pictures
$('#pictures img').click(function () {
$('.veryhighz-index').removeClass('veryhighz-index');
$(this).addClass('veryhighz-index');
});