イベントが発砲を停止するわけではありません。イベントでdivをクリックしていないだけです。
zIndexはコンテナを基準にしているため、zIndexingには注意してください。親よりもzIndexの少ないコンテナを持つことはできません。または、背後に移動させることができます。 「汚れた」ソリューションは、のZIndexは、すべてのクリックと一緒に成長することです:クロームの
<style type="text/css">
html, body{
width: 100%;
height: 100%;
}
.Movable{
height: 100px;
position: absolute;
width: 100px;
}
.black{
background-color: black;
}
.gray{
background-color: gray;
}
.wheat{
background-color: lightgray;
}
<div style="position: relative; z-index: 20;">
<p id="log" style="height: 1em; overflow-y: scroll;"></p>
<div onclick="log('clicked', this)" onmousedown="log('mousedown', this)" onmouseup="log('mouseup', this)" class="Movable black"></div>
<div onclick="log('clicked', this)" onmousedown="log('mousedown', this)" onmouseup="log('mouseup', this)" style="left: 25px; top: 55px;" class="Movable gray"></div>
<div onclick="log('clicked', this)" onmousedown="log('mousedown', this)" onmouseup="log('mouseup', this)" style="left: 55px; top: 75px;" class="Movable wheat"></div>
</div>
<script type="text/javascript">
var index = 1;
function log(msg, element)
{
element.style.zIndex = index++;
document.getElementById('log').innerHTML += "Log: " + msg + " -> " + element.className + "</br>";
}
</script>
作品は、IE11(OPさんはしませんでした)上で動作し、Firefoxの上で動作するように続けています。 (私は便利なものです)Nice!奇妙な、脆弱性の面で私を心配するだろう。しかし、素敵な! –
これは完璧に動作します!どうもありがとうございました。 –
イベントに触れるよりも簡単に見え、本当にうまくいきます。 +1私はあまりにも多くの兄弟/子供に注意する - パフォーマンスを傷つける可能性がある(私は思うOPの問題ではない) –