Advertisement
Guest User

Untitled

a guest
Aug 6th, 2022
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.86 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <style>
  7.         #a{
  8.             display:none;
  9.         }
  10.         #a .item{
  11.             width: 200px;
  12.             height: 200px;
  13.             background-color: #5af;
  14.         }
  15.         #b .item{
  16.             width: 200px;
  17.             height: 200px;
  18.             background-color: #f93;
  19.         }
  20.     </style>
  21. </head>
  22. <body>
  23.     <div class="box" id="a">
  24.         <div class="item"></div>
  25.     </div>
  26.     <div class="box" id="b">
  27.         <div class="item"></div>
  28.     </div>
  29.    
  30.     <script>
  31.     function isVisible(element) {
  32.           return element && (
  33.               element.clientHeight !== 0 ||
  34.               element.getClientRects().length !== 0 ||
  35.               getComputedStyle(element).display !== 'none'
  36.         );
  37.     }
  38.     a = document.querySelector("#a .item");
  39.     b = document.querySelector("#b .item");
  40.     alert("Is blue tile visible: " + isVisible(a)
  41.         + "\nIs orange tile visible " + isVisible(b));
  42.     </script>
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement