function updateSelect(e) {
const { target } = e;
const value = target.value;
const cadenceRow = inputCadence.closest(".form__row");
const elevationRow = inputElevation.closest(".form__row");
// Remove the hidden class from both rows first
cadenceRow.classList.remove("form__row--hidden");
elevationRow.classList.remove("form__row--hidden");
const selected = {
cycling: elevationRow,
running: cadenceRow,
};
selected[value].classList.add("form__row--hidden");
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter