Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- <style>
- #a{
- display:none;
- }
- #a .item{
- width: 200px;
- height: 200px;
- background-color: #5af;
- }
- #b .item{
- width: 200px;
- height: 200px;
- background-color: #f93;
- }
- </style>
- </head>
- <body>
- <div class="box" id="a">
- <div class="item"></div>
- </div>
- <div class="box" id="b">
- <div class="item"></div>
- </div>
- <script>
- function isVisible(element) {
- return element && (
- element.clientHeight !== 0 ||
- element.getClientRects().length !== 0 ||
- getComputedStyle(element).display !== 'none'
- );
- }
- a = document.querySelector("#a .item");
- b = document.querySelector("#b .item");
- alert("Is blue tile visible: " + isVisible(a)
- + "\nIs orange tile visible " + isVisible(b));
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement