javascript可以判断元素是否位于其他元素之上?

问题描述 投票:2回答:3

javascript可以判断元素是否位于其他元素之上?

考虑这个标记:

<!doctype html>
<html>
<style>
section div {width: 100px; position: absolute; border: 1px solid black; }
</style>
<body>
    <section>
        <div id="div1" style="height: 400px; background: blue;"></div>
        <div id="div2" style="height: 300px; background: red;"></div>
        <div id="div3" style="height: 200px; background: yellow;"></div>
        <div id="div4" style="height: 100px; background: green;"></div>
    </section>
</body>
</html>

我怎么知道(例如)div3下是否有什么东西?

javascript
3个回答
© www.soinside.com 2019 - 2024. All rights reserved.