mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 10:14:29 -07:00
24 lines
725 B
JavaScript
24 lines
725 B
JavaScript
document.addEventListener("DOMContentLoaded", () => {
|
|
const $grid = document.getElementById("grid");
|
|
const $columns = document.querySelectorAll(".jsColumns");
|
|
|
|
$columns.forEach(($) =>
|
|
$.addEventListener(
|
|
"input",
|
|
(event) => {
|
|
const count = event.target.valueAsNumber;
|
|
const suffix = event.target.dataset.suffix;
|
|
console.log("Column count", count);
|
|
$grid.className = `grid has-${count}-cols${suffix}`;
|
|
const $columnsCount = getAll("strong", $.parentNode);
|
|
$columnsCount.innerHTML = count;
|
|
},
|
|
false
|
|
)
|
|
);
|
|
|
|
function getAll(selector, parent = document) {
|
|
return Array.prototype.slice.call(parent.querySelectorAll(selector), 0);
|
|
}
|
|
});
|