✨closing button [x]
const { log } = console
// ⭐️ import
import { $, $all } from './js/ext/Node_ext.js'; // 👔 Node + ext
// ---------------------------------------------------------------
// elements
const panes = $all('.pane'); // <div class="pane">
panes.forEach(pane => {
// ⭐️ create "[x] buttons"
pane.insertAdjacentHTML(
"afterbegin",
'<div class="x-button">[x]</div>'
);
// ⭐️ <div class="x-button"> becomes `pane.firstChild`
pane.firstChild.onclick = () => {
pane.hidden = true;
};
});
// show all panes again
$('#showAll').onclick = () => {
panes.forEach(pane => pane.hidden = false);
};Last updated