mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 10:14:29 -07:00
Add grid interactions
This commit is contained in:
23
docs/_javascript/playground.js
Normal file
23
docs/_javascript/playground.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user