js

mail@pastecode.io avatar
unknown
plain_text
2 months ago
540 B
1
Indexable
Never
document.addEventListener("DOMContentLoaded", (event) => {
  // show initial widget values
  updateWidgetDisplay();

  // listen for input events that bubble up
  document.querySelector("#buttons").addEventListener("input", (event) => {
    updateWidgetDisplay();
  });
});

function updateWidgetDisplay() {
  let toggleValues = [];
  document.querySelectorAll("toggle-button").forEach((widget) => {
    toggleValues.push(widget.value);
  });
  document.querySelector("#button-values").innerHTML = toggleValues.join(", ");
}
Leave a Comment