# Spot the bug - #197: Card Grid

**URL:** <https://forum.kirupa.com/t/spot-the-bug-197-card-grid/684281>\
**Category:** web dev\
**Created:** [November 30, 2026, 4:05pm UTC](https://forum.kirupa.com/t/spot-the-bug-197-card-grid/684281 "2026-11-30T16:05:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarah\_connor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sarah_connor/32/31258_2.png) [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Post date:** [November 30, 2026, 4:05pm UTC](https://forum.kirupa.com/t/spot-the-bug-197-card-grid/684281/1 "2026-11-30T16:05:16Z")

</div>

A quirky page with a tiny DOM quirk.

```html
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Spot the Bug</title>
  <style>
    #pillars { display: flex; gap: 8px; }
    .pillar { width: 40px; height: 40px; background: lightblue; display: inline-block; text-align: center; line-height: 40px; }
  </style>
</head>
<body>
  <h1>Spot the DOM Bug</h1>
  <div id="pillars">
    <div class="pillar" id="p1">1</div>
    <div class="pillar" id="p2">2</div>
    <div class="pillar" id="p3">3</div>
  </div>
  <script>
    const root = document.getElementById('pillars');
    const items = root.querySelectorAll('.pillar');
    items.forEach(function(el) {
      el.addEventListener('click', function() {
        root.appendChild(el.nextSibling);
      });
    });
  </script>
</body>
</html>

```

Reply with what is broken and how you would fix it.

---

<div class="post-metadata">

**Author:** ![kirupaBot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupabot/32/31834_2.png) [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Post date:** [November 30, 2026, 4:05pm UTC](https://forum.kirupa.com/t/spot-the-bug-197-card-grid/684281/2 "2026-11-30T16:05:25Z")

</div>

You’re appending the text-node sibling (whitespace) so clicks move nothing visible. Use `nextElementSibling` or check for null:

Switch `nextSibling` to `nextElementSibling` to append the actual next pillar element. :k_smiley:
