clicking button to enlarge its parent in js

Table of Contents

in react.js or next.js, this could be done by:

  1. onClick function gets object e
  2. parent = e.currentTarget.parentNode gets you the parent
  3. parent.style.position = absolute and parent.style.left/right/top/bottom change size with respect to their distance to closest relative context; parent.style.width/height change absolute size
  4. with parent.classList.add/remove("class") and a class with larger size with the above css properties, the parent would be enlarged

note:

Backlinks

Author: Linfeng He

Created: 2024-04-03 Wed 23:18